Maybe an earlier callback can be added to CamelContextConfiguration? But instead of using that callback you can use some spring annotation that creates this component and name it wmq. Then Camel lookup in the spring bean registry for "wmq" when it wants to use the component with that name, and uses your bean.
On Fri, Sep 25, 2015 at 11:56 AM, Jimmy Selgen Nielsen <jimmy.sel...@gmail.com> wrote: > >> On 25. sep. 2015, at 11.42, Claus Ibsen <claus.ib...@gmail.com> wrote: >> >> I would favor configuring this on the component and name it wmq, then >> the endpoints can be simply as you want. >> >> So maybe something with >> >> @Bean("wmq") >> JmsComponent myWmqComponent() { >> ... >> } >> >> Not sure what the spring annotation is for assigning a name. >> > > Hmmm, not sure if i understand what you mean. > > Here’s what i’m currently doing (simplified for clarity - might not compile) > > @Bean > public CamelContextConfiguration contextConfiguration() { > return new CamelContextConfiguration() { > > public void beforeApplicationStart(CamelContext camelContext) > { > IBMWebSphereMqDestinationResolver > ibmWebSphereMqDestinationResolver = new IBMWebSphereMqDestinationResolver(); > > ConnectionFactory connectionFactory = > connectionFactoryMap().get("wmq"); > connectionFactory = > setupJmsConnectionCaching(connectionFactory); > connectionFactory = > setupJmsLogging(connectionFactory); > JmsComponent wmq = new JmsComponent(camelContext); > wmq.setConnectionFactory(connectionFactory); > > wmq.setDestinationResolver(ibmWebSphereMqDestinationResolver); > String componentName = "wmq; > camelContext.addComponent(componentName, wmq); > } > }; > } > > This works well, but when starting the application, the routes get configured > before the wmq endpoint is enabled : > 2015-09-25 10:20:39.845 INFO 10208 --- [ main] > d.b.m.router.routes.MainframeRouter : Starting listener : INPUT_QUEUE > 2015-09-25 10:20:40.057 INFO 10208 --- [ main] d.b.m.CamelConfig > : Registering component wmq > > Now when i define a deadLetterQueue: > ErrorHandlerBuilder ehb = > deadLetterChannel(backoutQueue).maximumRedeliveries(1); > from(String.format(“wmq:queue:%s", dest.getIn_queue_name()))…. > > I get this: > 2015-09-25 11:52:41.085 INFO 12760 --- [ main] > d.b.m.router.routes.MainframeRouter : Starting listener : INPUT_QUEUE > 2015-09-25 11:52:41.101 ERROR 12760 --- [ main] > o.s.boot.SpringApplication : Application startup failed > > java.lang.RuntimeException: org.apache.camel.ResolveEndpointFailedException: > Failed to resolve endpoint: wmq://queue:INPUT_QUEUE_BACKOUT due to: No > component found with scheme: wmq > at > org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:62) > at > org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:33) > > /J > -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2nd edition: https://www.manning.com/books/camel-in-action-second-edition