Samples - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

JMS is used in many examples for other components as well. But we provide a few samples below to get started.

Receiving from JMS

In the following sample we configure a route that receives JMS messages and routes the message to a POJO:

from("jms:queue:foo").to("bean:myBusinessLogic");

You can of course use any of the EIP patterns so the route can be context based. For example, here's how to filter an order topic for the big spenders:

from("jms:topic:OrdersTopic")
   .filter().method("myBean", "isGoldCustomer")
   .to("jms:queue:BigSpendersQueue");

Sending to a JMS

In the sample below we poll a file folder and send the file content to a JMS topic. As we want the content of the file as a TextMessage instead of a BytesMessage, we need to convert the body to a String :

from("file://orders")
   .convertBodyTo(String.class).
   .to("jms:topic:OrdersTopic");

Using Annotations

Camel also has annotations so you can use POJO Consuming and POJO Producing.

Spring DSL sample

The preceding examples use the Java DSL. Camel also supports Spring XML DSL. Here is the big spender sample using Spring DSL:

<route>
   <from uri="jms:topic:OrdersTopic"/>
   <filter>
      <method bean="myBean" method="isGoldCustomer"/>
      <to uri="jms:queue:BigSpendersQueue"/>
   </filter>
</route>

Other samples

JMS appears in many of the examples for other components and EIP patterns, as well in the online Apache Camel documentation. A recommended tutorial is this one that uses JMS but focuses on how well Spring Remoting and Camel work together Tutorial-JmsRemoting.