You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Krzysztof Burghardt <kr...@burghardt.pl> on 2010/03/03 13:06:10 UTC
How to configure Camel to route messages between two ActiveMQ
brokers?
Dear Users,
I'm trying to configure Apache Camel to consume messages from one
ActiveMQ broker, change format of message (this is actually
unimportant) and produce new message in queue located on another
ActiveMQ broker. Brokers cannot be directly connected.
I have created this Spring XML file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:ftpserver="http://mina.apache.org/ftpserver/spring/v1"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="activemq1"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost:61616"/>
</bean>
<bean id="activemq2"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost:61717"/>
</bean>
<camel:camelContext>
<camel:route id="route1">
<camel:from uri="activemq1:queue:in1"/>
<camel:to uri="activemq2:queue:out1"/>
</camel:route>
<camel:route id="route2">
<camel:from uri="activemq2:queue:in2"/>
<camel:to uri="activemq1:queue:out2"/>
</camel:route>
</camel:camelContext>
</beans>
What I got from logger is:
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | [ WrapperListener_start_runner] MainSupport
INFO Apache Camel 2.2.0 starting
jvm 1 | [ WrapperListener_start_runner]
ClassPathXmlApplicationContext INFO Refreshing
org.springframework.context.support.ClassPathXmlApplicationContext@1a7bf11:
display name [org.springframework.context.support.ClassPathXmlApplicationContext@1a7bf11];
startup date [Wed Mar 03 11:30:18 CET 2010]; root of context hierarchy
jvm 1 | [ WrapperListener_start_runner] XmlBeanDefinitionReader
INFO Loading XML bean definitions from file [C:\Documents and
Settings\krzysztof.burghardt\Pulpit\curtis-svn\trunk\lihi_inst2\cameld\dist\conf\META-INF\spring\camel.xml]
jvm 1 | [ WrapperListener_start_runner] CamelNamespaceHandler
INFO camel-osgi.jar/camel-spring-osgi.jar not detected in
classpath
jvm 1 | [ WrapperListener_start_runner]
ClassPathXmlApplicationContext INFO Bean factory for application
context [org.springframework.context.support.ClassPathXmlApplicationContext@1a7bf11]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@29c58e
jvm 1 | [ WrapperListener_start_runner] DefaultListableBeanFactory
INFO Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@29c58e:
defining beans [activemq1,activemq2,template,consumerTemplate,camelContext:beanPostProcessor,camelContext];
root of factory hierarchy
jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
INFO Apache Camel 2.2.0 (CamelContext:camelContext) is starting
jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
INFO JMX enabled. Using DefaultManagedLifecycleStrategy.
jvm 1 | [ WrapperListener_start_runner] BrokerService
INFO Using Persistence Adapter:
AMQPersistenceAdapter(activemq-data\localhost)
jvm 1 | [ WrapperListener_start_runner] AMQPersistenceAdapter
INFO AMQStore starting using directory: activemq-data\localhost
jvm 1 | [ WrapperListener_start_runner] KahaStore
INFO Kaha Store using data directory
activemq-data\localhost\kr-store\state
jvm 1 | [ WrapperListener_start_runner] AMQPersistenceAdapter
INFO Active data files: []
jvm 1 | [ WrapperListener_start_runner] BrokerService
INFO ActiveMQ 5.3.0 JMS Message Broker (localhost) isstarting
jvm 1 | [ WrapperListener_start_runner] BrokerService
INFO For help or more information please see:
http://activemq.apache.org/
jvm 1 | [ WrapperListener_start_runner] KahaStore
INFO Kaha Store using data directory
activemq-data\localhost\kr-store\data
jvm 1 | [ WrapperListener_start_runner] BrokerService
INFO ActiveMQ JMS Message Broker (localhost,
ID:CEN540B40K21-4808-1267612220976-0:0) started
jvm 1 | [ WrapperListener_start_runner] TransportConnector
INFO Connector vm://localhost Started
jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
INFO Started 2 routes
jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
INFO Apache Camel 2.2.0 (CamelContext:camelContext) started
jvm 1 | [ JMX connector] ManagementContext
INFO JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
And my question is: why it tries to start its own broker and connect
to it, and does not connect to brokers already running?
Best regards,
--
Krzysztof Burghardt <kr...@burghardt.pl>
http://www.burghardt.pl/
Re: How to configure Camel to route messages between two ActiveMQ
brokers?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You should use the tcp protocol instead of vm in your AMQ component.
Camel is just the client, you still need 2 real AMQ servers.
On Wed, Mar 3, 2010 at 1:06 PM, Krzysztof Burghardt
<kr...@burghardt.pl> wrote:
> Dear Users,
>
> I'm trying to configure Apache Camel to consume messages from one
> ActiveMQ broker, change format of message (this is actually
> unimportant) and produce new message in queue located on another
> ActiveMQ broker. Brokers cannot be directly connected.
>
> I have created this Spring XML file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:camel="http://camel.apache.org/schema/spring"
> xmlns:ftpserver="http://mina.apache.org/ftpserver/spring/v1"
> xmlns:amq="http://activemq.apache.org/schema/core"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd">
>
> <bean id="activemq1"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <property name="brokerURL" value="vm://localhost:61616"/>
> </bean>
>
> <bean id="activemq2"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <property name="brokerURL" value="vm://localhost:61717"/>
> </bean>
>
> <camel:camelContext>
> <camel:route id="route1">
> <camel:from uri="activemq1:queue:in1"/>
> <camel:to uri="activemq2:queue:out1"/>
> </camel:route>
> <camel:route id="route2">
> <camel:from uri="activemq2:queue:in2"/>
> <camel:to uri="activemq1:queue:out2"/>
> </camel:route>
> </camel:camelContext>
>
> </beans>
>
> What I got from logger is:
>
> wrapper | --> Wrapper Started as Console
> wrapper | Launching a JVM...
> jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
> jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
> jvm 1 |
> jvm 1 | [ WrapperListener_start_runner] MainSupport
> INFO Apache Camel 2.2.0 starting
> jvm 1 | [ WrapperListener_start_runner]
> ClassPathXmlApplicationContext INFO Refreshing
> org.springframework.context.support.ClassPathXmlApplicationContext@1a7bf11:
> display name [org.springframework.context.support.ClassPathXmlApplicationContext@1a7bf11];
> startup date [Wed Mar 03 11:30:18 CET 2010]; root of context hierarchy
> jvm 1 | [ WrapperListener_start_runner] XmlBeanDefinitionReader
> INFO Loading XML bean definitions from file [C:\Documents and
> Settings\krzysztof.burghardt\Pulpit\curtis-svn\trunk\lihi_inst2\cameld\dist\conf\META-INF\spring\camel.xml]
> jvm 1 | [ WrapperListener_start_runner] CamelNamespaceHandler
> INFO camel-osgi.jar/camel-spring-osgi.jar not detected in
> classpath
> jvm 1 | [ WrapperListener_start_runner]
> ClassPathXmlApplicationContext INFO Bean factory for application
> context [org.springframework.context.support.ClassPathXmlApplicationContext@1a7bf11]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@29c58e
> jvm 1 | [ WrapperListener_start_runner] DefaultListableBeanFactory
> INFO Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@29c58e:
> defining beans [activemq1,activemq2,template,consumerTemplate,camelContext:beanPostProcessor,camelContext];
> root of factory hierarchy
> jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
> INFO Apache Camel 2.2.0 (CamelContext:camelContext) is starting
> jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
> INFO JMX enabled. Using DefaultManagedLifecycleStrategy.
> jvm 1 | [ WrapperListener_start_runner] BrokerService
> INFO Using Persistence Adapter:
> AMQPersistenceAdapter(activemq-data\localhost)
> jvm 1 | [ WrapperListener_start_runner] AMQPersistenceAdapter
> INFO AMQStore starting using directory: activemq-data\localhost
> jvm 1 | [ WrapperListener_start_runner] KahaStore
> INFO Kaha Store using data directory
> activemq-data\localhost\kr-store\state
> jvm 1 | [ WrapperListener_start_runner] AMQPersistenceAdapter
> INFO Active data files: []
> jvm 1 | [ WrapperListener_start_runner] BrokerService
> INFO ActiveMQ 5.3.0 JMS Message Broker (localhost) isstarting
> jvm 1 | [ WrapperListener_start_runner] BrokerService
> INFO For help or more information please see:
> http://activemq.apache.org/
> jvm 1 | [ WrapperListener_start_runner] KahaStore
> INFO Kaha Store using data directory
> activemq-data\localhost\kr-store\data
> jvm 1 | [ WrapperListener_start_runner] BrokerService
> INFO ActiveMQ JMS Message Broker (localhost,
> ID:CEN540B40K21-4808-1267612220976-0:0) started
> jvm 1 | [ WrapperListener_start_runner] TransportConnector
> INFO Connector vm://localhost Started
> jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
> INFO Started 2 routes
> jvm 1 | [ WrapperListener_start_runner] DefaultCamelContext
> INFO Apache Camel 2.2.0 (CamelContext:camelContext) started
> jvm 1 | [ JMX connector] ManagementContext
> INFO JMX consoles can connect to
> service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
>
> And my question is: why it tries to start its own broker and connect
> to it, and does not connect to brokers already running?
>
> Best regards,
> --
> Krzysztof Burghardt <kr...@burghardt.pl>
> http://www.burghardt.pl/
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus