You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SHTherkildsen <So...@Systematic.com> on 2016/02/16 08:08:15 UTC
An issue with NotifyBuilder on nested routes
I seem to be having an issue with using NotifyBuilder on a nested route, when
using "direct:..." consumer. fromRoute(...).whenDone(..) and
from(...).whenDone(...) do not seem to Work in my case.
I am running camel 2.16.2 on a windows 8 box.
The test below fails on the testFromRouteDirect and testFromEndpointDirect
test cases. Is that a bug or intended behaviour?
---
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
import java.util.concurrent.TimeUnit;
public class NotifyWhenNestedRouteIsDone extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:a")
.routeId("A")
.to("seda:doStuffLater")
.to("direct:doStuffNow")
.log(LoggingLevel.INFO, "Did stuff");
from("seda:doStuffLater")
.routeId("B")
.log(LoggingLevel.INFO, "Procrastinating");
from("direct:doStuffNow")
.routeId("C")
.log(LoggingLevel.INFO, "Doing stuff");
}
};
}
@Test
public void testFromRouteSeda() {
NotifyBuilder nb = new
NotifyBuilder(context).fromRoute("B").whenDone(1).create();
Exchange exchange = new DefaultExchange(context);
exchange = template.send("direct:a", exchange);
boolean done = nb.matches(5, TimeUnit.SECONDS);
assertTrue("Timed out waiting for notify builder fromRoute(B)",
done);
}
@Test
public void testFromEndpointSeda() {
NotifyBuilder nb = new
NotifyBuilder(context).from("seda:doStuffLater").whenDone(1).create();
Exchange exchange = new DefaultExchange(context);
exchange = template.send("direct:a", exchange);
boolean done = nb.matches(5, TimeUnit.SECONDS);
assertTrue("Timed out waiting for notify builder
from(seda:doStuffLater)", done);
}
@Test
public void testFromRouteDirect() {
NotifyBuilder nb = new
NotifyBuilder(context).fromRoute("C").whenDone(1).create();
Exchange exchange = new DefaultExchange(context);
exchange = template.send("direct:a", exchange);
boolean done = nb.matches(5, TimeUnit.SECONDS);
assertTrue("Timed out waiting for notify builder fromRoute(C)",
done);
}
@Test
public void testFromEndpointDirect() {
NotifyBuilder nb = new
NotifyBuilder(context).from("direct:doStuffNow").whenDone(1).create();
Exchange exchange = new DefaultExchange(context);
exchange = template.send("direct:a", exchange);
boolean done = nb.matches(5, TimeUnit.SECONDS);
assertTrue("Timed out waiting for notify builder
from(seda:doStuffNow)", done);
}
}
---
Kind regards
Søren
--
View this message in context: http://camel.465427.n5.nabble.com/An-issue-with-NotifyBuilder-on-nested-routes-tp5777774.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: An issue with NotifyBuilder on nested routes
Posted by SHTherkildsen <So...@Systematic.com>.
The behaviour seems to be different for a nested route with a seda consumer.
At least my two test cases are working when I use NotifyBuilder on the
nested route with the seda consumer.
--
View this message in context: http://camel.465427.n5.nabble.com/An-issue-with-NotifyBuilder-on-nested-routes-tp5777774p5777777.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: An issue with NotifyBuilder on nested routes
Posted by Claus Ibsen <cl...@gmail.com>.
from is the first route the message was received into Camel. So in
your use-case it would always be "direct:a" as that is where you send
the message into Camel.
On Tue, Feb 16, 2016 at 8:08 AM, SHTherkildsen
<So...@systematic.com> wrote:
> I seem to be having an issue with using NotifyBuilder on a nested route, when
> using "direct:..." consumer. fromRoute(...).whenDone(..) and
> from(...).whenDone(...) do not seem to Work in my case.
>
> I am running camel 2.16.2 on a windows 8 box.
>
> The test below fails on the testFromRouteDirect and testFromEndpointDirect
> test cases. Is that a bug or intended behaviour?
>
> ---
> import org.apache.camel.Exchange;
> import org.apache.camel.LoggingLevel;
> import org.apache.camel.builder.NotifyBuilder;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.impl.DefaultExchange;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Test;
>
> import java.util.concurrent.TimeUnit;
>
> public class NotifyWhenNestedRouteIsDone extends CamelTestSupport {
>
> @Override
> protected RouteBuilder createRouteBuilder() throws Exception {
> return new RouteBuilder() {
> @Override
> public void configure() throws Exception {
>
> from("direct:a")
> .routeId("A")
> .to("seda:doStuffLater")
> .to("direct:doStuffNow")
> .log(LoggingLevel.INFO, "Did stuff");
>
> from("seda:doStuffLater")
> .routeId("B")
> .log(LoggingLevel.INFO, "Procrastinating");
>
> from("direct:doStuffNow")
> .routeId("C")
> .log(LoggingLevel.INFO, "Doing stuff");
> }
> };
> }
>
> @Test
> public void testFromRouteSeda() {
> NotifyBuilder nb = new
> NotifyBuilder(context).fromRoute("B").whenDone(1).create();
> Exchange exchange = new DefaultExchange(context);
> exchange = template.send("direct:a", exchange);
> boolean done = nb.matches(5, TimeUnit.SECONDS);
> assertTrue("Timed out waiting for notify builder fromRoute(B)",
> done);
> }
>
> @Test
> public void testFromEndpointSeda() {
> NotifyBuilder nb = new
> NotifyBuilder(context).from("seda:doStuffLater").whenDone(1).create();
> Exchange exchange = new DefaultExchange(context);
> exchange = template.send("direct:a", exchange);
> boolean done = nb.matches(5, TimeUnit.SECONDS);
> assertTrue("Timed out waiting for notify builder
> from(seda:doStuffLater)", done);
> }
>
> @Test
> public void testFromRouteDirect() {
> NotifyBuilder nb = new
> NotifyBuilder(context).fromRoute("C").whenDone(1).create();
> Exchange exchange = new DefaultExchange(context);
> exchange = template.send("direct:a", exchange);
> boolean done = nb.matches(5, TimeUnit.SECONDS);
> assertTrue("Timed out waiting for notify builder fromRoute(C)",
> done);
> }
>
> @Test
> public void testFromEndpointDirect() {
> NotifyBuilder nb = new
> NotifyBuilder(context).from("direct:doStuffNow").whenDone(1).create();
> Exchange exchange = new DefaultExchange(context);
> exchange = template.send("direct:a", exchange);
> boolean done = nb.matches(5, TimeUnit.SECONDS);
> assertTrue("Timed out waiting for notify builder
> from(seda:doStuffNow)", done);
> }
> }
> ---
>
> Kind regards
> Søren
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/An-issue-with-NotifyBuilder-on-nested-routes-tp5777774.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2