Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CAMEL-7252

...

This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a Spring service. The route works in a synchronous fashion returning a response to the client.

Table of Contents

Prerequisites

This tutorial uses Maven to setup the Camel project and for dependencies for artifacts.

...

Pattern

Description

Message Channel

We need a channel so the Clients can communicate with the server.

Message

The information is exchanged using the Camel Message interface.

Message Translator

This is where Camel shines as the message exchange between the Server and the Clients are text based strings with numbers. However our business service uses int for numbers. So Camel can do the message translation automatically.

Message Endpoint

It should be easy to send messages to the Server from the the clients. This is archived achieved with Camels powerful Endpoint pattern that even can be more powerful combined with Spring remoting. The tutorial have has clients using each kind of technique for this.

Point to Point Channel

We using JMS queues so there are only one receive of the message exchange The client and server exchanges data using point to point using a JMS queue.

Event Driven Consumer

Yes the The JMS broker is of course event driven and only reacts is invoked when the client sends a message to the server.

We use the following Camel components:

...

Info

For the purposes of the tutorial a single Maven project will be used for both the client and server. Ideally you would break your application down into the appropriate components.

Code Block

mvn archetype:create -DgroupId=org.example -DartifactId=CamelWithJmsAndSpring

...

The Camel Maven Plugin allows you to run your Camel routes directly from Maven. This negates the need to create a host application, as we did with Camel server, simply to start up the container. This can be very useful during development to get Camel routes running quickly.

Code Block
titlepom.xml

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>

...

Camel has extensive support for JMX and allows us to inspect the Camel Server at runtime. As we have enabled the JMXAgent in our tutorial we can fire up the jconsole and connect to the following service URI: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel. Notice that Camel will log at INFO level the JMX Connector URI:

Code Block

...
DefaultInstrumentationAgent    INFO  JMX connector thread started on service:jmx:rmi:///jndi/rmi://claus-acer:1099/jmxrmi/camel
...

...