You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2023/06/07 07:19:00 UTC
[jira] [Resolved] (CAMEL-19422) camel-core using a thread to stop a route from a route
[ https://issues.apache.org/jira/browse/CAMEL-19422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-19422.
---------------------------------
Resolution: Invalid
Please ask such question first in the user mailing list / or chat room
> camel-core using a thread to stop a route from a route
> ------------------------------------------------------
>
> Key: CAMEL-19422
> URL: https://issues.apache.org/jira/browse/CAMEL-19422
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 3.20.3
> Reporter: Shashank Mugatkar
> Priority: Major
> Labels: camel, route, thread
> Attachments: log.txt
>
>
> I have multiple messages which should be sent to a MQ 'foo'. After sending a message from 'route-1', the program should wait for a reply on MQ 'bar'. Only after getting a reply on queue 'bar', the next message should be sent.
> [How can I stop a route from a route :: Apache Camel|https://camel.apache.org/manual/faq/how-can-i-stop-a-route-from-a-route.html]
> I have followed the steps given in the documentation. All the messages are getting routed and then the route is getting suspended.
> *input.txt*
> {{}}
> {noformat}
> {noformat}
> {{msg1,msg2,msg3,msg4,msg5}}
>
> *beans.xml*
>
> {code:java}
> <camelContext id="orc-1" xmlns="http://camel.apache.org/schema/spring">
> <route id="route-1">
> <from uri="file://D://camelInput?fileName=input.txt" />
> <split>
> <tokenize token="," />
> <log message="${body}" />
> <to uri="jms:queue:foo" />
> <process ref="postProcessor" />
> </split>
> </route>
> <route id="route-2">
> <from uri="jms:queue:bar" />
> <!--restart route-1-->
> </route>
> </camelContext> {code}
>
> *{{PostProcessor.java}}*
>
> {code:java}
> public class PostProcessor implements Processor {
> Thread stop;
> @Override
> public void process(Exchange exchange) throws Exception {
> // stop this route using a thread that will stop
> // this route gracefully while we are still running
> if (stop == null) {
> stop = new Thread() {
> @Override
> public void run() {
> try {
> exchange.getContext().getRouteController().suspendRoute("route-1");
> } catch (Exception e) {
> // ignore
> }
> }
> };
> }
> // start the thread that stops this route
> stop.start();
> }
> }
> {code}
> **
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)