Reputation: 143
Base Facts : Apache Camel 2.20.1 (Spring Boot)
Multiple context reference in same spring boot config xml throws below highlighted error, despite providing explicit different ids
When my own example failed - I tried with simple sample case.. but met with the same error
Error creating bean with name 'typeConverter' defined in class path resource >[org/apache/camel/spring/boot/TypeConversionConfiguration.class]: Unsatisfied >dependency expressed through method 'typeConverter' parameter 0; nested >exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: >No qualifying bean of type 'org.apache.camel.CamelContext' available: expected >single matching bean but found 2: camel1,camel2
<!-- here we have the 1st CamelContext -->
<camelContext id="camel1" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:one" />
<to uri="mock:result" />
</route>
</camelContext>
<!-- and there we have the 2nd CamelContext -->
<camelContext id="camel2" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:two" />
<to uri="log:two" />
<to uri="mock:result" />
</route>
</camelContext>
My context are being called from Spring boot starter class as follows.
@SpringBootApplication
@ComponentScan(basePackages="com.wm")
@ImportResource("classpath:META-INF/spring/spring-context.xml")
public class ExtAuthServiceAppStarter {
public static void main(String[] args) {
SpringApplication.run(ExtAuthServiceAppStarter.class, args);
}
}
Any suggestions ?
Upvotes: 2
Views: 4497
Reputation: 739
I think you can do that : you have to specify the context in ProducerTemplate tag named @Produce like this :
@Produce(uri = "direct:JMS:export:JMS", context = "camel1")
ProducerTemplate exportProducer
Upvotes: 0
Reputation: 616
Right, you can't have multiple Camel Context.
One option to consider, having routes you want to include inside a Route Context instead of a Camel Context. A Route Context is like a subset of a Camel Context. Then you reference the Route Contexts you want to import and Camel will add them to the context.
Reference : https://tomd.xyz/multiple-camel-contexts/
Upvotes: 0
Reputation: 55750
Yes Spring Boot is not an application server to host N+ applications in the same JVM.
Camel on Spring Boot is optimized and adhered to run one CamelContext only.
Upvotes: 3