Announcement Announcement Module
Collapse
No announcement yet.
Publishing Messages to a JMS Queue in Batches Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Publishing Messages to a JMS Queue in Batches

    Need to be able to publish messages to a JMS queue in batches ( e.g. so they can be read in a single JMS message by the consumer ):

    Code:
    message 1 -->                 
    message 2 --> [Agregator?] {completion interval or # of messages reached} => send List<Message> off to the queue
    message N -->
    Looks like I can use an Aggregator for that. However it feels a bit like a pattern abuse, since according to the implementation, it seems to aggregate messages that relate to each other ( e.g. group id, correlation id, etc.. ). Whereas in my case grouping / collecting is just for batching purposes, and messages are completely unrelated.

    1. Is there a known component / strategy to use that I overlooked?

    2. If an 'Aggregator' is the component to use, where to look to implement "timeout" and "# of messages"?

    2.1 I can see a "timeout" property on the Aggregator => "The timeout interval for sending the aggregated messages to the output or reply channel" is that it? It has this "expire" feel to it, which is not really suits my use case, would it still be feasible to abuse it for "release this batch of messages every 2 seconds"? e.g. Camel has a "completionInterval: A repeating period in millis by which the aggregator will complete all current aggregated exchanges. Camel has a background task which is triggered every period". But I don't see anything similar on SI Aggregator.

    2.2 If "ReleaseStrategy" should be used, how / can it be used for both: a "release interval" and a "message count" e.g. (pseudo code):

    Code:
    release-strategy-expression="every #this.releaseInterval() OR #this.size() gt 5"
    edit:

    2.3 "TimeoutCountSequenceSizeReleaseStrategy" looks interesting, although does not really implement an "interval" => the "timeout" is calculated on the "next" message, rather than via "a background task which is triggered every period".

    At this point I am trying to see if SI is a fit here at all, or I'd be just better off by using a "JmsTemplate" + "ScheduledExecutorService"...

    Thank you!
    Last edited by spinter; Feb 6th, 2012, 05:28 PM.
Working...
X