Is there a way that I can autowire bean on my route without using the .bean keyword in Camel?

Let's say, for example, I have the following route:

          from(.....)
          .choice()
          .when(condition1)
          .bean(Class1.class,"method1")
          .when(condition2)
           .bean(Class1.class,"method2")
          .otherwise()
          .bean(Class1.class,"method3")
          .end();

Is there a way that autwire Class1 can use all methods instead of using the .bean function on a camel. If you know any other effective method. Please let me know. Hope to hear from you soon.

Thanks Gautham

+4
source share
1 answer

you have some more options ...

  • can use bean to refer to spring bean

    from("direct:hello").to("bean:bye");
    
  • can use beanRef () API to refer to spring bean

    from("direct:start").beanRef("beanName", "methodName");
    
  • can use annotation for input and bean () API to reference bean

    @Autowired
    Private MyService myService;
    ...
    from("direct://start").bean(myservice, "process");
    
+6
source

Source: https://habr.com/ru/post/1589264/


All Articles