4 Replies Latest reply on Apr 15, 2016 1:06 AM by Tomohisa igarashi

    Injecting CDI Bean into Camel RouteBuilder

    Max Ozkin Apprentice

      Invoking a Bean component from a Camel component is not a problem in Switchyard, if you use a component reference and invoke the bean via to("switchyard://BeanService").

      But what if you want to use bean's methods directly in the route's code for one reason or another, for example as below. Is it then possible to simply inject a bean?



          private InternalService service;


          public void configure() {



                  .process(new Processor() {


                      public void process(Exchange exchange) throws Exception {

                          service.foo(); // <- here service is null !!





      It doesn't work for me. It seems InternalService doesn't get injected. At least, when this route is invoked, "service" is null.

      Similar approach works fine for Bean switchyard components.

      I attached a complete project. SwitchYard is 1.1.