Search code examples
apache-camelcamel-test

camel test replace seda with direct in original route


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 "); 
    }
    })

Solution

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