Maybe you could implement a custom RoutePolicy to stop, then restart your route from the top after a certain fixed number of messages are processed.

http://camel.apache.org/routepolicy.html

On 10/4/2013 6:30 AM, prgtrdr wrote:
Thanks for trying to help Robert.  Let me clarify my confusing post.

I'm writing a GUI app that shows inventory level for a widget.  The level
changes periodically as customers buy and we receive replenishment.  So the
GUI updates the quantity on hand as soon as a purchase is made, then when
another purchase is made in 2 minutes it would update then, then we receive
new supply in 4 minutes another update shows at that time, etc.  The GUI
reads all these events from an ActiveMQ topic so I can have multiple
instances subscribed simultaneously.

For testing I wrote an order simulator program that attaches to the topic
and sends order events with random delays between each message.  The GUI
reacts appropriately, i.e., I can see the levels change periodically.  Now
the sales force wants to play with the program for acceptance but they want
to be able to look at it continuously.  To do this they need to see the
screen change but if I leave the order simulator program running it will
generate thousands of unneeded messages and clog up my server.

Instead, I realize that I can replay the messages that I already sent to the
topic by adding destination.consumer.retroactive=true to the <from>
endpoint.  But when the messages play back there is no delay between them so
the screen just shows the result after the last message.  The sales people
are confused.  I need to slow it down.  So I added a delay to my DSL as
follows:

         <route>
                 <description>Slow producer simulation for
Orders</description>
                 <from
uri="activemq:topic:Tester/Orders?destination.consumer.retroactive=true"/>
                 <log message="Delaying write of Order ${body} to Simulator
topic"/>
                 <delay><constant>2000</constant></delay>
                 <to uri="activemq:topic:Tester/Orders/Simulator"/>
         </route>

Now the GUI changes every 2 seconds.  But once we read the last message on
the topic the route just waits for more messages that never come in (because
the simulator isn't running).  What I need is a way to restart the route
once we reach the end of the messages on the topic.

I'm thinking that I could use a Polling Consumer EIP with receiveNoWait and
if a null Exchange is received, I should schedule a new instance of the
route, and then stop the current route.  But I'm at a loss as to how to do
this with XML.  Can you help?

Thanks,
Bill



--
View this message in context: 
http://camel.465427.n5.nabble.com/Simulating-a-periodic-producer-tp5740783p5740867.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to