You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ghazi Naceur <gh...@gmail.com> on 2018/08/25 17:54:25 UTC

Exception when sending message to queue

Hello everyone,

I am facing the following issue :

Caused by: org.apache.camel.NoSuchBeanException: No bean could be
found in the registry of type: PlatformTransactionManager
    at org.apache.camel.model.TransactedDefinition.doResolvePolicy(TransactedDefinition.java:247)
~[camel-core-2.22.0.jar:2.22.0]
    at org.apache.camel.model.TransactedDefinition.resolvePolicy(TransactedDefinition.java:181)
~[camel-core-2.22.0.jar:2.22.0]
    at org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:158)
~[camel-core-2.22.0.jar:2.22.0]
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:562)
~[camel-core-2.22.0.jar:2.22.0]
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:523)
~[camel-core-2.22.0.jar:2.22.0]
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:239)
~[camel-core-2.22.0.jar:2.22.0]
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1343)
~[camel-core-2.22.0.jar:2.22.0]
    ... 23 common frames omitted


My camel route is :

public void configure() throws Exception {
    from("activemq:queue:inbound.endpoint")
            .transacted()
            .log(LoggingLevel.INFO, log, "Received message")
            .process(exchange -> {
                LOGGER.info("Exchange : {}", exchange);
            })
            .process(exchange -> {
                Object obj = exchange.getIn().getBody(Object.class);
                repository.insertIntoElasticsearch(obj);
            })
            .to("activemq:queue:outbound.endpoint")
            .log(LoggingLevel.INFO, log, "Message sent.")
            .end();
}

My code :

CamelContext context = new DefaultCamelContext();
context.addRoutes(new JmsRoute());
ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://0.0.0.0:61616");
context.addComponent("jms",
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
ProducerTemplate template = context.createProducerTemplate();
context.start();
template.sendBody("activemq:queue:inbound.endpoint", new Person("10",
"firstName","lastName",29, "Occupation"));



My pom.xml file :

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>2.22.0</version>
</dependency>

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jms</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-client</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-pool</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-kahadb-store</artifactId>
</dependency>



I appreciate you help.

Re: Exception when sending message to queue

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
You’ve configured the route to use an XA transaction (the .transacted() ), but it doesn’t look like you’ve configured the connection factories and such for XA.

If you can get away with it, you could try “tranacted=true” on both the subscriber and the publisher - it’s not as fail-safe as XA, but I use the pattern quite a bit because it meets my needs and is its much easier to configure.


HTH

> On Aug 25, 2018, at 11:54 AM, Ghazi Naceur <gh...@gmail.com> wrote:
> 
> Hello everyone,
> 
> I am facing the following issue :
> 
> Caused by: org.apache.camel.NoSuchBeanException: No bean could be
> found in the registry of type: PlatformTransactionManager
>    at org.apache.camel.model.TransactedDefinition.doResolvePolicy(TransactedDefinition.java:247)
> ~[camel-core-2.22.0.jar:2.22.0]
>    at org.apache.camel.model.TransactedDefinition.resolvePolicy(TransactedDefinition.java:181)
> ~[camel-core-2.22.0.jar:2.22.0]
>    at org.apache.camel.model.TransactedDefinition.createProcessor(TransactedDefinition.java:158)
> ~[camel-core-2.22.0.jar:2.22.0]
>    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:562)
> ~[camel-core-2.22.0.jar:2.22.0]
>    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:523)
> ~[camel-core-2.22.0.jar:2.22.0]
>    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:239)
> ~[camel-core-2.22.0.jar:2.22.0]
>    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1343)
> ~[camel-core-2.22.0.jar:2.22.0]
>    ... 23 common frames omitted
> 
> 
> My camel route is :
> 
> public void configure() throws Exception {
>    from("activemq:queue:inbound.endpoint")
>            .transacted()
>            .log(LoggingLevel.INFO, log, "Received message")
>            .process(exchange -> {
>                LOGGER.info("Exchange : {}", exchange);
>            })
>            .process(exchange -> {
>                Object obj = exchange.getIn().getBody(Object.class);
>                repository.insertIntoElasticsearch(obj);
>            })
>            .to("activemq:queue:outbound.endpoint")
>            .log(LoggingLevel.INFO, log, "Message sent.")
>            .end();
> }
> 
> My code :
> 
> CamelContext context = new DefaultCamelContext();
> context.addRoutes(new JmsRoute());
> ConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://0.0.0.0:61616");
> context.addComponent("jms",
> JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
> ProducerTemplate template = context.createProducerTemplate();
> context.start();
> template.sendBody("activemq:queue:inbound.endpoint", new Person("10",
> "firstName","lastName",29, "Occupation"));
> 
> 
> 
> My pom.xml file :
> 
> <dependency>
>    <groupId>org.apache.camel</groupId>
>    <artifactId>camel-spring-boot-starter</artifactId>
>    <version>2.22.0</version>
> </dependency>
> 
> <dependency>
>    <groupId>org.apache.camel</groupId>
>    <artifactId>camel-jms</artifactId>
> </dependency>
> <dependency>
>    <groupId>org.apache.activemq</groupId>
>    <artifactId>activemq-camel</artifactId>
> </dependency>
> <dependency>
>    <groupId>org.apache.activemq</groupId>
>    <artifactId>activemq-client</artifactId>
> </dependency>
> <dependency>
>    <groupId>org.apache.activemq</groupId>
>    <artifactId>activemq-broker</artifactId>
> </dependency>
> <dependency>
>    <groupId>org.apache.activemq</groupId>
>    <artifactId>activemq-pool</artifactId>
> </dependency>
> <dependency>
>    <groupId>org.apache.activemq</groupId>
>    <artifactId>activemq-kahadb-store</artifactId>
> </dependency>
> 
> 
> 
> I appreciate you help.