mule jms transport

15
Mule ESB 3.6 Java Messaging Services (JMS) Prepared By: Rupesh Sinha

Upload: rupeshkrsinha

Post on 18-Jul-2015

311 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Mule JMS Transport

Mule ESB 3.6

Java Messaging Services (JMS)

Prepared By: Rupesh Sinha

Page 2: Mule JMS Transport

Overview

− Java Messaging Services (JMS)

− JMS Messaging model

− JMS backchannel

− Message filters in JMS

− JMS transformers in Mule

− Example configuration for ActiveMQ

Page 3: Mule JMS Transport

Java Messaging Services (JMS)

• A message oriented middleware

• Supports creation of message based

applications

• Supports loosely coupled middleware

• Supports transactions

• Supports reliability

Page 4: Mule JMS Transport

JMS Messaging Model

• JMS supports two models for messaging

− JMS Queue

− JMS Topic

Page 5: Mule JMS Transport

JMS Queue

• Standard Queuing

• First In First Out (FIFO)

• Point to point i.e., single producer and single

consumer

• The behavior is similar to Mule VM queues

Page 6: Mule JMS Transport

JMS Topic

• Enables publish and subscribe mechanism

• The model is similar to RSS feed

• Multiple subscribers can subscribe to a topic

• Supports publishing a message even if subscriber is

disconnected using durable attribute in mule JMS

Message Publisher

Message Subscriber 1 Message Subscriber 2 Message Subscriber N

Page 7: Mule JMS Transport

JMS backchannel

• Backchannel allows response to be returned back in synchronous mule

message flow

• There are two ways to create backchannel in Mule

− Define your outbound endpoint with request-response exchange pattern

− Use a request-reply message processor

• Backchannel allows JMS endpoint to behave as two way channel

• It internally sets “reply-to” header that tells mule where to send a

response

Client ServerChannel

Backchannel

Transport

Page 8: Mule JMS Transport

Message filter in JMS

• Mule supports selecting specific messages at

the consumers end by using JMS selector

• JMS selector can use JMS header properties

• Non matching messages remains in the queue

<jms:inbound-endpoint connector-ref="Active_MQ" doc:name="ActiveMQ" topic="TestTopic">

<jms:selector expression="JMSPriority=5" />

</jms:inbound-endpoint>

Page 9: Mule JMS Transport

JMS transformers in Mule

• The default transformers applied to JMS endpoints are as

follows:

− inbound = JMSMessageToObject

− outbound = ObjectToJMSMessage

− response = ObjectToJMSMessage

• The transformation happens to/from as given below

JMS Type Java Type

javax.jms.TextMessage java.lang.String

javax.jms.ObjectMessage java.lang.Object

javax.jms.BytesMessage byte[]

javax.jms.MapMessage java.util.Map

javax.jms.StreamMessage java.io.InputStream

Page 10: Mule JMS Transport

Example configuration for Active MQ

• Configuring a JMS connector using ActiveMQ

• Defining JMS outbound endpoint

• Defining JMS inbound endpoint

• The example configuration for JMS connector

and inbound/outbound endpoints are given in

coming slides and configuration is using a JMS

topic

Page 11: Mule JMS Transport

Configuring a JMS connector using Active MQ

<jms:activemq-connector name="Active_MQ" specification="1.1" username="username"

password="password" brokerURL="tcp://host:port" validateConnections="true"

doc:name="Active MQ"/>

Page 12: Mule JMS Transport

Defining JMS outbound endpoint

<jms:outbound-endpoint topic="TestTopic" connector-ref="Active_MQ" doc:name="JMS"/>

Page 13: Mule JMS Transport

Defining JMS inbound endpoint

<jms:inbound-endpoint connector-ref="Active_MQ“ doc:name="ActiveMQ" topic="TestTopic"/>

Page 14: Mule JMS Transport

For more details, please refer the MuleSoft reference document at below URL

http://www.mulesoft.org/documentation/display/current/JMS+Transport+Reference

Page 15: Mule JMS Transport

Thanks for watching