You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gbchriste <ga...@gmail.com> on 2015/12/10 17:53:43 UTC

Route Setup Advice

The application I'm dealing with receives and processes XML messages from a
back end service.  The messages fall in to 2 basic categories which I'll
call fast messages and slow messages.

Fast messages are all of the same type and format, just different values in
the XML elements.  They are all handled by the same internal process.  They
arrive from the back end at the rate of about 40 per second.

Slow messages can be one of about 7 or 8 different types and formats but
only arrive at the rate of about 1 every 3 minutes, and each is handled by a
different internal process.  

Given the rate of arrival of fast messages and the consistency of
processing, I don't want to waist time filtering those out from the rest.  
And conversely, given the slower rate of arrival of slow messages, I see no
harm in taking the time to filter those.

So I'm thinking of establishing 2 routes for the incoming messages.  One
route dedicated just to the fast messages, and a second route for slow
messages that applies a selector to send each to it's required processor.

Here's something along the lines of what I have in mind:


from("activemq:topic:fastmessages").bean("MessageProcessor.class,
"ProcessFastMessage);

from("activemq:topic:slowmessages").choice()
    .when(header("MessageType").isEqualTo("SlowMessage1"))
         .bean(MessageProcessor.class, "ProcessSlowMessage1")
    .when(header("MessageType").isEqualTo("SlowMessage2"))
          .bean(MessageProcessor.class, "ProcessMessage2")
    .when(header("MessageType).isEqualTo("SlowMessage3"))
          .bean(MessageProcessor.class, "ProcessMessage3");


Advisable?  Yes/No?  Any pitfalls or traps I need to lookout for?

Any and all help appreciated.

Thanks,

Gary
                    



--
View this message in context: http://camel.465427.n5.nabble.com/Route-Setup-Advice-tp5774950.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route Setup Advice

Posted by gbchriste <ga...@gmail.com>.
Yes.  If you look at the example code I have 2 routes, one subscribing to
activemq:topic:fastmessages and one subscribing to
activemq:topic:slowmessages

All of the messages coming down the pipe from the fastmessages topic go
straight to the handler for that message type.  In the real app this happens
to be a steady stream of air traffic data with each message carrying
latitude, longitude, altitude, speed, et al for an aircraft, and gets passed
through to a method that plots the target up on a map display.

Messages coming down the pipe from the slowmessages are of various
informational content and will get routed and processed according to their
content.

The backend service that is publishing the messages put each message in to
the appropriate topic, and also set the messagetype header if it is a
slowmessage



--
View this message in context: http://camel.465427.n5.nabble.com/Route-Setup-Advice-tp5774950p5774955.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route Setup Advice

Posted by riddellg <gr...@libertymutual.com>.
Implied from your sample but just checking - you're planning on using MQ
topics to separate the 2 classes of message? Makes it really simple on the
service side (I like what you have) but the client does need to be aware of
the topics and publish to the correct one. 



--
View this message in context: http://camel.465427.n5.nabble.com/Route-Setup-Advice-tp5774950p5774952.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route Setup Advice

Posted by gbchriste <ga...@gmail.com>.
I like the succinctness of this but I think I'll stick with an explicit route
for each messagtype/processor for now.  One of the main goals I'm trying to
achieve is to straighten out and clarify a rather convoluted and
difficult-to-comprehend pile of code created by the contractor that wrote
the original application.  It has taken me literally over a year to get to
the point where I can follow through all the twists and turns that it takes. 
So I want my fix to be clear and immediately understandable by the next
person that has to take this over.  

As I get further in I may decide to use this more elegant approach but for
now I think having the message type and target processor specified in the
route will help achieve one of my main goal.

Thanks for the input! 



--
View this message in context: http://camel.465427.n5.nabble.com/Route-Setup-Advice-tp5774950p5774957.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Route Setup Advice

Posted by Greg Autric <ga...@redhat.com>.
Hi Gary,

You can also use more dynamic stuff for slow messages route

from("direct:slowMessage").toD("bean:foo?method=Process${header.MessageType}");

but you have to check ${header.MessageType} to avoid NoSuchMethod

as riddellg said, I think Client just wants push message without thinking about slow or fast messages.
  
best regards,

Greg AUTRIC                        
JBoss Middleware Consultant

email   : gautric __at__ redhat __dot__ com
twitter : @gautric_io

Red Hat Global Services            
Red Hat France SARL                sit: http://www.redhat.fr
Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
Sent from webmail

----- Mail original -----
De: "gbchriste" <ga...@gmail.com>
À: users@camel.apache.org
Envoyé: Jeudi 10 Décembre 2015 17:53:43
Objet: Route Setup Advice

The application I'm dealing with receives and processes XML messages from a
back end service.  The messages fall in to 2 basic categories which I'll
call fast messages and slow messages.

Fast messages are all of the same type and format, just different values in
the XML elements.  They are all handled by the same internal process.  They
arrive from the back end at the rate of about 40 per second.

Slow messages can be one of about 7 or 8 different types and formats but
only arrive at the rate of about 1 every 3 minutes, and each is handled by a
different internal process.  

Given the rate of arrival of fast messages and the consistency of
processing, I don't want to waist time filtering those out from the rest.  
And conversely, given the slower rate of arrival of slow messages, I see no
harm in taking the time to filter those.

So I'm thinking of establishing 2 routes for the incoming messages.  One
route dedicated just to the fast messages, and a second route for slow
messages that applies a selector to send each to it's required processor.

Here's something along the lines of what I have in mind:


from("activemq:topic:fastmessages").bean("MessageProcessor.class,
"ProcessFastMessage);

from("activemq:topic:slowmessages").choice()
    .when(header("MessageType").isEqualTo("SlowMessage1"))
         .bean(MessageProcessor.class, "ProcessSlowMessage1")
    .when(header("MessageType").isEqualTo("SlowMessage2"))
          .bean(MessageProcessor.class, "ProcessMessage2")
    .when(header("MessageType).isEqualTo("SlowMessage3"))
          .bean(MessageProcessor.class, "ProcessMessage3");


Advisable?  Yes/No?  Any pitfalls or traps I need to lookout for?

Any and all help appreciated.

Thanks,

Gary
                    



--
View this message in context: http://camel.465427.n5.nabble.com/Route-Setup-Advice-tp5774950.html
Sent from the Camel - Users mailing list archive at Nabble.com.