Wednesday, 15 January 2014

spring - Consuming given amount of messages from channel with period -


The first question for Artem Bilan (I work with my former colleagues) < / P>

I have these types of flows:

  • to get a dataset (obstruction in flow due to DB
  • Each static to send JMS using
  • CHAIN_OF_TRANSFORMATORS JmsTemplate

Time will have to send different messages (this is something "profile" by By "10,20,100 ..." the structure has been provided, which means "send 10 messages during the first minute, 20 minutes during the second minute, 100 messages on the third minute .."). The execution of the period is trivial enough, it is provided by PeriodicPoller .

This problem is the first part of the need. Table row by using JdbcPollingChannelAdapter by using the SqlParameterSource is a matter of obtaining the given amount, but the "hindered" reason does not fit according to the above mentioned "N" channel Receiving messages "is possible?

I tried to implement it with some release stroccity on the channel next to the adapter, but if the voter helps me from time to time, Will describe in the manner of use.

There is additional difficulty with describing integration flow references using Java DSL, during this time most examples use XML.

Thanks for any suggestions

After private discussions with Dimitri, Come up with this solution.

Requirements

  • Read the special amount of messages and send them one by one to the JMS queue
  • At every survey interval The amount of messages changes
  • Send messages and compare them with the amount required for that particular election task. If they are not equal, an error report is generated, that there was not enough message for voting.

Solution

  1. Change max messaging for the end point on each survey & lt; Poller & gt; PollerMetadata ) has recommendation option
  2. with this we have some custom advice ( MethodInterceptor )
  3. Inject our PollingConsumer invocation.proceed ()
  4. maxmessagesPerPoll from AtomicInteger from Bean to Use #preSend and reset to increase ChannelInterceptor In that advice
  5. In addition to the maxMessagesPerPoll, in the consultation with the previous voting Can see the reaction of with counter.

No comments:

Post a Comment