Tuhin
Tuhin

Reputation: 3373

How to use camel between to server and client's activemq

I am able to send messages from one queue to another queue in same activemq server. But my requirement is : a)There will be two host- my system(as server) and virtual box(as client). b)Both will have own activemq queue and camel.

Now the problem is - how can I send message from server's queue to client's queue using server's camel? and vice-verse.

please help me out. Any solution will be appreciated. Thank you very much

Upvotes: 1

Views: 1315

Answers (1)

Petter Nordlander
Petter Nordlander

Reputation: 22279

It's a pretty basic concept to connect to different servers from a Camel instance. It, however, depends a bit on how you have it configured/deployed. Given you have your Camel running in Spring inside your ActiveMQ, you can simply setup two camel-activemq components. You need to give correct broker URLs, queue names etc.

<bean id="localamq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
        <property name="connectionFactory">
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="vm://localhost?create=false"/>
            <property name="userName" value="${activemq.username}"/>
            <property name="password" value="${activemq.password}"/>
          </bean>
        </property>
    </bean>

<bean id="remoteamq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
        <property name="connectionFactory">
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="tcp://otherserver:61616"/>
          </bean>
        </property>
    </bean>


  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="localamq:some.queue"/>
            <to uri="remoteamq:some.other.queue"/>
        </route>
    </camelContext>

Upvotes: 3

Related Questions