Hello Claus Right, so
1. I cannot send a message without blocking because the event calback seems to be triggered BEFORE the CamelContext is fully up and running. That's kind of counter intuitive. I would imagine that when Spring's ApplicationContext has been fully initialized all the beans are fully initialized and ready to go... including CamelContext and all the routes.... 2. I cannot block in that method not to deadlock the whole Spring machinery. Fair enough. So I need to spawn a new thread that I assume needs to poke the CamelContext about whether it's state is 'started'....ok, can do that, but perhaps it's not the most elegant solution. Any reason why Camel cannot be fully up and running before Spring? Cheerio Artur On Tue, Apr 11, 2017 at 3:34 PM, Claus Ibsen <[email protected]> wrote: > Dont use the event listener to do code that may block > @EventListener(ContextRefreshedEvent.class) > > You are basically hi-jacking the spring thread that signals this > event. You can create a new thread to send the message from the event > listener so you dont block it. > > > > > On Tue, Apr 11, 2017 at 1:30 PM, Artur Jablonski > <[email protected]> wrote: > > Hello, > > > > I have the Camel + Spring + SpringBoot combo working > > > > > > I have my RouteBilder Spring Component that's being pickup up and started > > during Spring startup. > > The route starts fine as I can see SpringCamelContext output in the logs. > > > > What I am trying to do is to send a message to direct endpoint using > > injected ProducerTemplate but if I do it like this > > > > @Produce(uri = "direct:myQueue") > > private ProducerTemplate producerTemplate; > > > > @EventListener(ContextRefreshedEvent.class) > > public void send() > > throws Exception > > { > > producerTemplate.start(); > > producerTemplate.sendBody("hello"); > > } > > > > > > I am getting > > > > No consumers available on endpoint: direct://myQueue > > > > because the route has not started yet and if I try blocking parameter on > > uri like this: > > > > @Produce(uri = "direct:myQueue?block=true") > > > > then the whole thing freezes for 30 secs (default timeout) and then blows > > up with the same exception > > > > I also tried to call the producerTemplate.sendBody() form @PostConstruct > > annotaded method with the same effect. > > > > > > How do I wait for the CamelContext to be fully started in this > context???? > > > > > > Cheerio > > Arur > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >
