eddyrokr
eddyrokr

Reputation: 414

Apache camel with external ActiveMQ broker

I am learning to use Apache Camel to solve a messaging problem. The following points explains the gist of the problem.

  1. There is an external ActiveMQ broker which expects a message in JSON format and returns a response in JSON format.
  2. The JSON message that is sent to the broker must be created during runtime, by getting a parameter from the user.
  3. The returned response is returned to the user.

I am finding it difficult to follow the book examples and fit it to my problem. Please let me know how this can be solved using Apache Camel.

Thanks!

Upvotes: 1

Views: 1773

Answers (1)

Ben ODay
Ben ODay

Reputation: 21015

just need to setup your activemq component like this

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

then define routes to produce/consume from ActiveMQ queues, convert to/from JSON as needed...

for example...one route to take the client request, convert to JSON and send to a queue

from("direct:clientRequest")
    .marshal().json()
    .to("activemq:firstQueue");

then another route to pickup from another queue and unmarshal from JSON and do something with it...

from("activemq:otherQueue")
    .unmarshal().json()
    .to("<do something>");

Upvotes: 4

Related Questions