You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by doug5791 <to...@uwgb.edu> on 2014/03/25 18:12:14 UTC
Camel: How to stop a route temporarily?
I am trying to see if I can increase the performance of my route by adding a
cache prior to a database write. I will describe the flow of the route I
would like below:
if( cacheSize != MAXCACHESIZE)
{
//Add the Exchange to the data structure but* do not* continue with the
write
//cacheSize++
}
else
{
//Flush the cache allowing the stored Exchanges to* continue* on the
route
}
Looking at the above pseudo-code, what I am trying to do is store routes
until a max has be reached and then write all of the stored Exchanges to the
DB while starting to collect the next batch.
I have looked into creating a bean to handle this as well as defining my own
processor, but neither has been successful. Using Camel-Cache and
Camel-streamCaching are not options for me.
Any ideas on how to halt the route while the cache is not full and continue
when flushing the cache?
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351.html
Sent from the Camel - Users mailing list archive at Nabble.com.
RE: Camel: How to stop a route temporarily?
Posted by doug5791 <to...@uwgb.edu>.
I am using this link: (http://camel.465427.n5.nabble.com/ProducerTemplate-for-sending-mails-with-attachements-td5605511.html) as a reference to create a new exchange in my processor and send that exchange to an endpoint.
However, the Exchange stops at that endpoint and does not continue -even to an inline processor-.
I am trying to set the SLIP_ENDPOINT property of the Exchanges manually, it is not working yet since I cannot test the arrival of Exchanges with a processor.
any ideas how to have the template.send(customExchange) enter a route and continue to the following endpoints from within an inline processor?
________________________________
From: Claus Ibsen-2 [via Camel] [ml-node+s465427n5749370h62@n5.nabble.com]
Sent: Wednesday, March 26, 2014 1:36 AM
To: Tober, Douglas Arlyn
Subject: Re: Camel: How to stop a route temporarily?
Hi
You can use some of these EIPs for dynamic routing behavior
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html
http://camel.apache.org/recipient-list.html
http://camel.apache.org/routing-slip.html
http://camel.apache.org/dynamic-router.html
On Tue, Mar 25, 2014 at 9:45 PM, doug5791 <[hidden email]<UrlBlockedError.aspx>> wrote:
> I guess the biggest thing I need to accomplish is telling all the exchanges that are stopped to go to the next endpoint.
>
> Is there something I can append like a property that says: "exchange.set property(Exchange.goToEndpoint, "database")"?
>
>
> "doug5791 [via Camel]" <[hidden email]<UrlBlockedError.aspx>> wrote:
>
> I am currently trying to use the "Exchange.ROUTE_STOP" property -I do not think that using a CountDownLatch will work out-, however I do not get the desired effect. Using the code below, only the last Exchange goes on to the database:
>
>
> //exAr is a List of Exchanges
> .process(new Processor()
> {
> public void process(Exchange exchange) throws Exception
> {
> //Check if cache is not full, add the exchange, set exchange to stop
> if(exAr.size() < CACHEMAXSIZE)
> {
> exAr.add(exchange);
> cacheSize++;
> exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
> }
>
> //Check if cache is full, iterate exchanges and set to go, clear cache
> if(exAr.size() == CACHEMAXSIZE)
> {
> for(int i = 0; i < CACHEMAXSIZE; i++)
> {
> exAr.get(i).setProperty(Exchange.ROUTE_STOP, Boolean.FALSE);
> }
> cacheSize = 0;
> exAr.clear();
> }
> }
> })
> .to("database")
> According to the documentation on using ROUTE_STOP this should be what I'm looking for. However only the last item in the List is sent on to the database.
>
> ________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749356.html
> To unsubscribe from Camel: How to stop a route temporarily?, click here<
> NAML<<UrlBlockedError.aspx>http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749360.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]<UrlBlockedError.aspx>
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io
________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749370.html
To unsubscribe from Camel: How to stop a route temporarily?, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5749351&code=dG9iZWRhMjFAdXdnYi5lZHV8NTc0OTM1MXwxNzM2OTQ0MzM3>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749401.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel: How to stop a route temporarily?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You can use some of these EIPs for dynamic routing behavior
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html
http://camel.apache.org/recipient-list.html
http://camel.apache.org/routing-slip.html
http://camel.apache.org/dynamic-router.html
On Tue, Mar 25, 2014 at 9:45 PM, doug5791 <to...@uwgb.edu> wrote:
> I guess the biggest thing I need to accomplish is telling all the exchanges that are stopped to go to the next endpoint.
>
> Is there something I can append like a property that says: "exchange.set property(Exchange.goToEndpoint, "database")"?
>
>
> "doug5791 [via Camel]" <ml...@n5.nabble.com> wrote:
>
> I am currently trying to use the "Exchange.ROUTE_STOP" property -I do not think that using a CountDownLatch will work out-, however I do not get the desired effect. Using the code below, only the last Exchange goes on to the database:
>
>
> //exAr is a List of Exchanges
> .process(new Processor()
> {
> public void process(Exchange exchange) throws Exception
> {
> //Check if cache is not full, add the exchange, set exchange to stop
> if(exAr.size() < CACHEMAXSIZE)
> {
> exAr.add(exchange);
> cacheSize++;
> exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
> }
>
> //Check if cache is full, iterate exchanges and set to go, clear cache
> if(exAr.size() == CACHEMAXSIZE)
> {
> for(int i = 0; i < CACHEMAXSIZE; i++)
> {
> exAr.get(i).setProperty(Exchange.ROUTE_STOP, Boolean.FALSE);
> }
> cacheSize = 0;
> exAr.clear();
> }
> }
> })
> .to("database")
> According to the documentation on using ROUTE_STOP this should be what I'm looking for. However only the last item in the List is sent on to the database.
>
> ________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749356.html
> To unsubscribe from Camel: How to stop a route temporarily?, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5749351&code=dG9iZWRhMjFAdXdnYi5lZHV8NTc0OTM1MXwxNzM2OTQ0MzM3>.
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749360.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io
Re: Camel: How to stop a route temporarily?
Posted by doug5791 <to...@uwgb.edu>.
I guess the biggest thing I need to accomplish is telling all the exchanges that are stopped to go to the next endpoint.
Is there something I can append like a property that says: "exchange.set property(Exchange.goToEndpoint, "database")"?
"doug5791 [via Camel]" <ml...@n5.nabble.com> wrote:
I am currently trying to use the "Exchange.ROUTE_STOP" property -I do not think that using a CountDownLatch will work out-, however I do not get the desired effect. Using the code below, only the last Exchange goes on to the database:
//exAr is a List of Exchanges
.process(new Processor()
{
public void process(Exchange exchange) throws Exception
{
//Check if cache is not full, add the exchange, set exchange to stop
if(exAr.size() < CACHEMAXSIZE)
{
exAr.add(exchange);
cacheSize++;
exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
}
//Check if cache is full, iterate exchanges and set to go, clear cache
if(exAr.size() == CACHEMAXSIZE)
{
for(int i = 0; i < CACHEMAXSIZE; i++)
{
exAr.get(i).setProperty(Exchange.ROUTE_STOP, Boolean.FALSE);
}
cacheSize = 0;
exAr.clear();
}
}
})
.to("database")
According to the documentation on using ROUTE_STOP this should be what I'm looking for. However only the last item in the List is sent on to the database.
________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749356.html
To unsubscribe from Camel: How to stop a route temporarily?, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5749351&code=dG9iZWRhMjFAdXdnYi5lZHV8NTc0OTM1MXwxNzM2OTQ0MzM3>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749360.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel: How to stop a route temporarily?
Posted by doug5791 <to...@uwgb.edu>.
I am currently trying to use the "Exchange.ROUTE_STOP" property -I do not
think that using a CountDownLatch will work out-, however I do not get the
desired effect. Using the code below, only the last Exchange goes on to the
database:
//exAr is a List of Exchanges
.process(new Processor()
{
public void process(Exchange exchange) throws Exception
{
//Check if cache is not full, add the exchange, set
exchange to stop
if(exAr.size() < CACHEMAXSIZE)
{
exAr.add(exchange);
cacheSize++;
exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
}
//Check if cache is full, iterate exchanges and set to
go, clear cache
if(exAr.size() == CACHEMAXSIZE)
{
for(int i = 0; i < CACHEMAXSIZE; i++)
{
exAr.get(i).setProperty(Exchange.ROUTE_STOP,
Boolean.FALSE);
}
cacheSize = 0;
exAr.clear();
}
}
})
.to("database")
According to the documentation on using ROUTE_STOP this should be what I'm
looking for. However only the last item in the List is sent on to the
database.
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351p5749356.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel: How to stop a route temporarily?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
There is this FAQ which may help
http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html
On Tue, Mar 25, 2014 at 6:12 PM, doug5791 <to...@uwgb.edu> wrote:
> I am trying to see if I can increase the performance of my route by adding a
> cache prior to a database write. I will describe the flow of the route I
> would like below:
>
> if( cacheSize != MAXCACHESIZE)
> {
> //Add the Exchange to the data structure but* do not* continue with the
> write
> //cacheSize++
> }
> else
> {
> //Flush the cache allowing the stored Exchanges to* continue* on the
> route
> }
>
> Looking at the above pseudo-code, what I am trying to do is store routes
> until a max has be reached and then write all of the stored Exchanges to the
> DB while starting to collect the next batch.
>
> I have looked into creating a bean to handle this as well as defining my own
> processor, but neither has been successful. Using Camel-Cache and
> Camel-streamCaching are not options for me.
>
> Any ideas on how to halt the route while the cache is not full and continue
> when flushing the cache?
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-How-to-stop-a-route-temporarily-tp5749351.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io