Sure enough, when I try to do pretty much the same thing from a JUnit test,
it works:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { Application.class })
public class CamelTest
{
@Produce(uri = "direct:myQueue")
protected ProducerTemplate template;
@Test
public void sendMessage()
{
template.sendBody(attachment);
}
}
so... what's the deal? If firing a message is a part of my application
logic... what's the recommended way of handling this?
Cheerio
Artur
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
>
>
>
>
>
>
>
>
>
>
>
>
>