0

camel test, replace seda with direct.

In my camel route test i wants to replace seda call with direct for example

instead of "seda:Second_route_id" my consumer should be "direct:Second_route_id" for test

Following is my original route

from("direct:First_route_id").id("First_route_id")
.process() // bla bla
.multicast()
.to("Second_route_id");

---
from("seda:Second_route_id").id("Second_route_id")
.proces() // save data
.end()

i tried to do some thing like

    context.getRouteDefination("First_route_id").adviceWith(context, new AdviceWithoutRouteBuilder(){
    public void configure(){
// but it gave me error no consumer found for "direct: Second_route_id"
    weaveById("Second_route_id").before().to("direct: Second_route_id "); 
    }
    })
d-man
  • 57,473
  • 85
  • 212
  • 296

2 Answers2

0

There is a replaceFromWith method you can use to change seda to direct when using advice with.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
0

replaceFromWith is one possible way:

    camelContext.getRouteDefinition("Second_route_id").adviceWith(camelContext, new AdviceWithRouteBuilder() {

        @Override
        public void configure() throws Exception {
            replaceFromWith("direct:Second_route_id");
        }
    });
Paizo
  • 3,986
  • 30
  • 45