Spring Book – Chapter 20 – Spring Integration

Messaging (JMS)

Spring Integration provides Channel Adapters for receiving and sending JMS messages. There are actually two JMS-based inbound Channel Adapters as follows:

  • Uses Spring’s JmsTemplate to receive based on a polling period
  • Relies on Spring’s Message Listener Container and is considered “message-driven” approach

In addition, Spring Integration has an outbound Channel Adapter that uses the JmsTemplate to convert and send a JMS Message on demand.

The JMS Channel Adapters are intended for unidirectional Messaging (send-only or receive-only), Spring Integration also provides inbound and outbound JMS Gateways for request/reply operations.

Listing 22-74 below shows the maven dependency required for supporting JMS support using Spring Integration.

Listing 22-74. Maven dependency required

Listing 22-75 below shows configuration of main Spring Integration namespace and JMS related namespace in the Spring configuration file (jms-integration-context.xml).

Listing 22-75. Spring Integration Namespace declaration

Listing 22-76 below shows configuring jms inbound channel adapter using Spring’s JmsTemplate

Listing 22-76. Configuring jms inbound channel adapter using JmsTemplate

Listing 22-77 below shows configuring jms inbound channel adapter using Spring’s Message Container Listener

Listing 22-77. Configuring jms inbound channel adapter using Message Container Listener

Listing 22-78 below shows configuring jms outbound channel adapter. In the below listing the configuration will produce an adapter that receives Spring Integration Messages from the “inputChannel” and then converts those into JMS Messages and sends them to the JMS Destination reference whose bean name is “outQueue”.

Listing 22-78. Configuring jms outbound channel adapter

Listing 22-79 and Listing 22-80 below shows, configuring JMS inbound gateway and outbound gateway repectively, in the Spring configuration file.

Listing 22-79. Configuring jms inbound gateway

Listing 22-80. Configuring jms outbound gateway

Page Visitors: 13409

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

2 thoughts on “Spring Book – Chapter 20 – Spring Integration

  1. Hi,
    Thanks for this blog and information sharing!
    I have one question from Spring Integration. Just thought of checking with you.
    I have SimplewebserviceOutBoundGateway. I need to send a document / attachment to the webservice. How will i achieve that?
    This is my current gateway configuration:

    Please let me know, if you can throw some light in this area.
    Thanks in Advance!

  2. Hi,
    Thank you for your information sharing.
    I have one doubt,could you please suggest me the correct frameworks to address that issue.

    My requirement is I would like to get and process files using spring and camel.


Leave a Reply

Your email address will not be published. Required fields are marked *