You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by krishy <ca...@gmail.com> on 2011/06/30 21:02:28 UTC

Maximum Number of Routes

This might be question that falls in the premature optimization category. 

I am working on a project where users create watch lists on the various
events in the system based on 
certain criteria and whenever the events that satisfy their criteria are
met, an email is sent to the user. Say
for example one user could create a watch that says "When ever the price of
Foobar product goes below $10, 
inform me", another could have a watch that says "Whenever the product Foo
is sold out email me" etc.,

The events are pushed out to a ActiveMQ topic and I had envisioned each of
these watch list items as a 
dynamically added route from the topic to an email end point. I had thought
about using recipient list but it 
got pretty messy quickly as it turned out to be a big if else statement.

This has a potential to explode to thousands of routes as each user could
configure multiple watches. I plan
 to test this out as well but would really like some feedback from the list.
Is this a safe approach to take? 
What determines the number of routes that can be configured in this case?

--
View this message in context: http://camel.465427.n5.nabble.com/Maximum-Number-of-Routes-tp4539803p4539803.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Maximum Number of Routes

Posted by Donald Whytock <dw...@gmail.com>.
Close.  More specifically, I mean the entire route can be shared...you
really should only need one route.

I assume you have a list of regexes and email addresses in a database?
 So for any given message, you compare it against the regexes and kick
off an email message for each match.

So your processor's constructor gets an endpoint for your SMTP server,
and from that gets a default producer.  Your processor's process()
does the database check, and for each hit cranks out a new exchange,
uses exchange.getIn().setHeader("to", emailaddress), generates the
appropriate text in exchange.getIn().setBody(), and sends it off.

Your one route consumes all the MQ exchanges.  No dynamic routing,
just dynamic exchange creation.

Sound like what you need?

Don


On Thu, Jun 30, 2011 at 4:44 PM, krishy <ca...@gmail.com> wrote:
>
> Donald Whytock wrote:
>>
>> You can do it with a single email endpoint that points to your SMTP
>> server, producing an exchange for each event for each user by putting
>> the destination email address in the message's "to" header.
>>
>
> Thanks and that is what I have planned. When ever the users informs their
> intent to watch an product the
> something like the following piece of code executes. Is this what you talk
> about when you say the end
>  point can be shared?
>
> void addRoutes(String selectorString, User user) throws Exception {
>      context.addRoutes(new RouteBuilder() {
>            from("activemq:topic:product?selector=" + selectorString).
>            .process(&lt;Sets the exchange with the message and to
> address&gt;)
>
> .to("smtp://mycompany.mailserver:30?password=tiger&username=scott");
>      });
> }
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Maximum-Number-of-Routes-tp4539803p4540083.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Maximum Number of Routes

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Instead of creating hundreds of routes at runtime, why not limit it to
hundred of endpoints. Endpoints are cheap, easily created, and have no
lifecycle/performance implications.

It would be far better to create a single route that dispatches the message
to a bean which then uses a ProducerTemplate to farm out the message
exchnage to any number of endpoints.

It is far more scalable and does not have a chance to overrun your system
with routes.

Cheers,

Ashwin... 

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
CamelOne 2011: http://fusesource.com/camel2011 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Maximum-Number-of-Routes-tp4539803p4542157.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Maximum Number of Routes

Posted by krishy <ca...@gmail.com>.
Donald Whytock wrote:
> 
> You can do it with a single email endpoint that points to your SMTP
> server, producing an exchange for each event for each user by putting
> the destination email address in the message's "to" header.
> 

Thanks and that is what I have planned. When ever the users informs their
intent to watch an product the 
something like the following piece of code executes. Is this what you talk
about when you say the end
 point can be shared?

void addRoutes(String selectorString, User user) throws Exception {
      context.addRoutes(new RouteBuilder() {
            from("activemq:topic:product?selector=" + selectorString).
            .process(&lt;Sets the exchange with the message and to
address&gt;)
           
.to("smtp://mycompany.mailserver:30?password=tiger&username=scott");
      });
}

--
View this message in context: http://camel.465427.n5.nabble.com/Maximum-Number-of-Routes-tp4539803p4540083.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Maximum Number of Routes

Posted by Donald Whytock <dw...@gmail.com>.
You can do it with a single email endpoint that points to your SMTP
server, producing an exchange for each event for each user by putting
the destination email address in the message's "to" header.

Don

On Thu, Jun 30, 2011 at 3:02 PM, krishy <ca...@gmail.com> wrote:
> This might be question that falls in the premature optimization category.
>
> I am working on a project where users create watch lists on the various
> events in the system based on
> certain criteria and whenever the events that satisfy their criteria are
> met, an email is sent to the user. Say
> for example one user could create a watch that says "When ever the price of
> Foobar product goes below $10,
> inform me", another could have a watch that says "Whenever the product Foo
> is sold out email me" etc.,
>
> The events are pushed out to a ActiveMQ topic and I had envisioned each of
> these watch list items as a
> dynamically added route from the topic to an email end point. I had thought
> about using recipient list but it
> got pretty messy quickly as it turned out to be a big if else statement.
>
> This has a potential to explode to thousands of routes as each user could
> configure multiple watches. I plan
>  to test this out as well but would really like some feedback from the list.
> Is this a safe approach to take?
> What determines the number of routes that can be configured in this case?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Maximum-Number-of-Routes-tp4539803p4539803.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Maximum Number of Routes

Posted by boday <be...@initekconsulting.com>.
same question...same answer

http://stackoverflow.com/questions/6336900/design-question-on-dynamic-apache-camel-routes-context/6347445#6347445


krishy wrote:
> 
> This might be question that falls in the premature optimization category. 
> 
> I am working on a project where users create watch lists on the various
> events in the system based on 
> certain criteria and whenever the events that satisfy their criteria are
> met, an email is sent to the user. Say
> for example one user could create a watch that says "When ever the price
> of Foobar product goes below $10, 
> inform me", another could have a watch that says "Whenever the product Foo
> is sold out email me" etc.,
> 
> The events are pushed out to a ActiveMQ topic and I had envisioned each of
> these watch list items as a 
> dynamically added route from the topic to an email end point. I had
> thought about using recipient list but it 
> got pretty messy quickly as it turned out to be a big if else statement.
> 
> This has a potential to explode to thousands of routes as each user could
> configure multiple watches. I plan
>  to test this out as well but would really like some feedback from the
> list. Is this a safe approach to take? 
> What determines the number of routes that can be configured in this case?
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/Maximum-Number-of-Routes-tp4539803p4540059.html
Sent from the Camel - Users mailing list archive at Nabble.com.