Announcement Announcement Module
No announcement yet.
PollableSource Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • PollableSource

    I want to have a class implementing this interface but it isn't recognised using the source-adapter ref attribute. It seems I can wire a method up such as T getData().

    Under the covers, the ChannelAdapterParser creates a MethodInvokingSource. I'd like it to use my PollableSource instead.

    Fyi - I am implementing functionality to retrieve events from another database.

    How should I implement this logic?

  • #2
    I'm a bit confused. Can you provide some code samples to explain what you're trying to do exactly?

    It would also help if you gave some more detail on the use case.


    • #3
      Code sample

      Ok, so I have this working:

      <source-adapter channel="events" method="hoover" ref="task-hoover" period="3000"/>
      <beans:bean id="task-hoover" class="stockroom.TaskHoover" />
      TaskHoover has a method signature and implementation:

      public Event hoover()
      	return new Event("Hello " + count++);
      With this the hoover() method is called every 3 seconds. This is good, but I need to return a collection of Event objects. (Use case is I am pulling event data from an external data source, then constructing event objects which go to the events channel which is pub-sub).

      What I want to do is implement the PollableSource interface in this class and be able to configure it using the source-adapter without passing the method ref.

      What I was saying before is that the ChannelAdapterParser creates a MethodInvokingSource which implements PollableSource when parsing a source-adapter. So how do I make use of a custom implementation of PollableSource. Is such an approach desirable?


      • #4
        This makes perfect sense to me, and it is consistent with other areas of Spring Integration (and Spring in general) where 'ref' alone is sufficient if the referenced bean implements a particular strategy interface. When the referenced bean does not implement the interface, then 'method' can be added to create a "MethodInvoking" adapter that does implement the interface. Can you create a Jira issue for this? We are planning some changes to the source-adapter approach in M4, and I would like to include the feature you've described here.



        • #5
          JIRA raised


          • #6
            Progress is starting on this issue. Note that it's part of a larger refactoring effort aimed at providing a more intuitive separation of "source" and "adapter". For example, any implementation of PollableSource should be capable of being scheduled and activated as a SourceAdapter. On the other hand, there are also cases where the source may only be required "on-demand". In that sense, a source is much like a MessageChannel. It is perfectly acceptable to call channel.receive() programmatically, but with the MessageBus, it is also possible to subscribe to the channel via a scheduled MessageDispatcher.

            That's the general idea, and as always feedback is much appreciated.



            • #7
              This should be possible now with the following configuration:
              <source-endpoint source="mySource" channel="myChannel">
                  <schedule period="60000"/>
              <beans:bean id="mySource" class="example.MyPollableSource"/>
              Note that this will work if you check out the SVN head (or a nightly snapshot >= ci.111):