You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Martin Gilday <ma...@imap.cc> on 2010/03/30 11:58:18 UTC
Stopped Routes
When looking around I've found examples [1] showing how to stop and
start routes in a CamelContext. However I've been unable to find how to
configure a route to be stopped at startup. Is it possible to do this?
[1]
http://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/StartAndStopRoutesTest.java
Re: Stopped Routes
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
See this FAQ about stopping a route from a route
http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html
On Wed, Aug 22, 2012 at 12:43 PM, hekonsek <he...@gmail.com> wrote:
> Hi Ritu,
>
>> how to will I configure XML so that route will only run once
>
> Access CamelContext in Processor and close the route via
> CamelContext#stopRoute().
>
> from("direct:stopRoute").
> process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> String routeId = exchange.getIn().getBody(String.class);
> exchange.getContext().stopRoute(routeId);
> }
> });
>
> Best regards.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Stopped-Routes-tp474159p5717843.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Stopped Routes
Posted by hekonsek <he...@gmail.com>.
Hi Ritu,
> how to will I configure XML so that route will only run once
Access CamelContext in Processor and close the route via
CamelContext#stopRoute().
from("direct:stopRoute").
process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String routeId = exchange.getIn().getBody(String.class);
exchange.getContext().stopRoute(routeId);
}
});
Best regards.
--
View this message in context: http://camel.465427.n5.nabble.com/Stopped-Routes-tp474159p5717843.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Stopped Routes
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
See the user guide there is a link to this
http://camel.apache.org/configuring-route-startup-ordering-and-autostartup.html
On Tue, Mar 30, 2010 at 11:58 AM, Martin Gilday <ma...@imap.cc> wrote:
> When looking around I've found examples [1] showing how to stop and
> start routes in a CamelContext. However I've been unable to find how to
> configure a route to be stopped at startup. Is it possible to do this?
>
> [1]
> http://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/StartAndStopRoutesTest.java
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
exhausted usage of splitter-pattern
Posted by ext2 <xu...@tongtech.com>.
Hi:
Previously , I have ask some question about splitter, and the
stream-based splitter pattern can resolve such situations:
Enumerate data from large external data source, and process each
data continuously until all data from external-data source is readed;
But resolve such problem, Usage of Camel's splitter pattern is very
exhausted; to illustrate it , let's have a example:
read a condition from jms queue. According to the condition ,
enumerate a external file's content line by line; and we do same operations
on each line;
Although we could use streamed splitter pattern to resolve this problem, as
following :
1: write my custom iterater to enumerate content from external file;
2: using streamed-splitter to process each line from file;
3: using a doTry-doFianlly to close the iterater;
But the real exhausted thing is how to close the iterator, while execute the
process concurrent-ly;
1) I must using a bean to create the iterator; it seems like :
2) I must close the iterator while split finished, it looks like
<dotry>
<splitter/>
<doFinally>
<bean ref="fileProcess"
method="closeLineIterator"/>
</doFianlly>
<dotry>
But configured as above cannot execute concurrently, because the bean itself
cannot ensure to close iterator thread-safely;
In order ensure concurrently execute safe, I must save iterator in the
Exchange's property and close it by property;
it looks like as following and the following things look like too exhausted.
So does camel provide a better choice to resolve such problems?
<setProperty name="iteratorId">
<method bean="fileProcess" method="createLineIterator"/>
<setProperty>
<doTry>
<split streaming="true">
<getProperty name="iteratorId">
...
</split><doFinally>
<process ref = "CloseIteratorByProperty"/> //here is too exhausted,
because I cannot get a bean from message and invoke it's method;
</doTry>
Class CloseIteratorByProperty implement Process
{
Void process(Exchange ex)
{
Iterator iter = Ex.getProperty("iteratorId");
((implementation class)iter).close();
}
}