View Full Version : PollableSource
Mar 20th, 2008, 04:47 AM
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?
Mar 20th, 2008, 06:00 PM
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.
Mar 25th, 2008, 05:11 AM
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?
Mar 25th, 2008, 07:03 AM
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.
Mar 26th, 2008, 04:22 AM
Apr 11th, 2008, 02:32 PM
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.
Apr 24th, 2008, 03:29 PM
This should be possible now with the following configuration:
<source-endpoint source="mySource" channel="myChannel">
<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): http://static.springframework.org/downloads/nightly/snapshot-download.php?project=INT
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.