From b9d375e8597e3abc536dd53c46e8c24f4ce6f807 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Tue, 21 Oct 2008 03:14:07 +0000 Subject: [PATCH] Added some coverage of JMS adapters --- spring-integration-reference/src/adapters.xml | 42 --------- spring-integration-reference/src/jms.xml | 88 ++++++++++++++++++- 2 files changed, 84 insertions(+), 46 deletions(-) diff --git a/spring-integration-reference/src/adapters.xml b/spring-integration-reference/src/adapters.xml index 30b9be394b..4ecaa2403d 100644 --- a/spring-integration-reference/src/adapters.xml +++ b/spring-integration-reference/src/adapters.xml @@ -40,48 +40,6 @@ -
- JMS Adapters - - Spring Integration provides two adapters for accepting JMS messages (as mentioned above): - JmsSource and JmsGateway. The former uses Spring's - JmsTemplate to receive based on a polling period. The latter configures and delegates to - an instance of Spring's DefaultMessageListenerContainer. - - - The JmsSource requires a reference to either a single JmsTemplate - instance or both ConnectionFactory and Destination - (a 'destinationName' can be provided in place of the 'destination' reference). The JmsSource - can then be referenced from a "channel-adapter" element that connects the source to a - MessageChannel instance. The following example defines a JMS source with - a JmsTemplate as a constructor-argument. - - -]]> - - - In most cases, Spring Integration's message-driven JmsGateway is more appropriate since it - delegates to a MessageListener container, supports dynamically adjusting - concurrent consumers, and can also handle replies. The JmsGateway requires references to - a ConnectionFactory, and a Destination (or - 'destinationName'). The following example defines a JmsGateway that receives from the JMS - queue called "exampleQueue". Note that the 'expectReply' property has been set to 'true' (it is 'false' by - default): - - - - -]]> - - - The JmsTarget implements the MessageTarget interface - and is capable of mapping Spring Integration Messages to JMS messages and then - sending to a JMS destination. It requires either a 'jmsTemplate' reference or both 'connectionFactory' and - 'destination' references (again, the 'destinationName' may be provided in place of the 'destination). In - , you will see how to configure a JMS target adapter with Spring - Integration's namespace support. - -
Mail Adapters diff --git a/spring-integration-reference/src/jms.xml b/spring-integration-reference/src/jms.xml index aa8140daf8..66178d061f 100644 --- a/spring-integration-reference/src/jms.xml +++ b/spring-integration-reference/src/jms.xml @@ -1,14 +1,94 @@ - + JMS Support + + Spring Integration provides Channel Adapters for receiving and sending JMS messages. The inbound Channel Adapter + uses Spring's JmsTemplate to receive based on a polling period, and the outbound Channel + Adapter uses the JmsTemplate to convert and send a JMS Message on demand. + + + Spring Integration also provides inbound and outbound JMS Gateways. The inbound gateway relies on Spring's + DefaultMessageListenerContainer for Message-driven reception that is also capable of sending + a return value to the "reply-to" Destination as provided by the received Message. The outbound Gateway uses a JMS + QueueRequestor for request/reply operations. In other words, while the inbound and outbound + Channel Adapters are for unidirectional Messaging, the Gateways are intended for handling request/reply operations. + -
- +
+ Inbound Channel Adapter - + The inbound Channel Adapter requires a reference to either a single JmsTemplate + instance or both ConnectionFactory and Destination + (a 'destinationName' can be provided in place of the 'destination' reference). The following example defines an + inbound Channel Adapter with a Destination reference. + ]]> + +
+
+ Outbound Channel Adapter + + The JmsSendingMessageConsumer implements the MessageConsumer + interface and is capable of converting Spring Integration Messages to JMS messages + and then sending to a JMS destination. It requires either a 'jmsTemplate' reference or both 'connectionFactory' and + 'destination' references (again, the 'destinationName' may be provided in place of the 'destination). As with the + inbound Channel Adapter, the easiest way to configure this adapter is with the namespace support. The following + configuration will produce an adapter that receives Spring Integration Messages from the "exampleChannel" and then + converts those into JMS Messages and sends them to the JMS Destination reference whose bean name is "outQueue". + ]]> + +
+ +
+ Inbound Gateway + + Spring Integration's message-driven JmsInboundGateway delegates to a + MessageListener container, supports dynamically adjusting concurrent consumers, and + can also handle replies. The JmsInboundGateway requires references to a + ConnectionFactory, and a Destination (or + 'destinationName'). The following example defines a JmsInboundGateway that receives from the JMS + queue called "exampleQueue" and sends to the Spring Integration channel named "exampleChannel". + ]]> + + + The default behavior for an outbound gateway is to reply with the Spring Integration Message as the JMS Message + body. This works well when you are connecting two systems that are both running Spring Integration-based + applications. However, if you prefer to just send the Spring Integration Message's payload as the JMS reply + Message's body, then set the "extract-payload-for-reply" attribute to "true". + +
+ +
+ Outbound Gateway + + The outbound Gateway uses a QueueRequestor so that reply Messages will be automatically + correlated. Notice that the "reply-channel" is also provided. + ]]> + + + For all of these JMS adapters, you can also specify your own "message-converter" reference. Simply provide the + bean name of an instance of MessageConverter that is available within the same + ApplicationContext. + +
+ +
+ JMS Samples + + To experiment with these JMS adapters, check out the samples available within the "jms" package of the + "org.springramework.integration.samples" module (in the distribution). There are two samples included. One + provides inbound and outbound Channel Adapters, and the other provided inbound and outbound Gateways. They are + configured to run with an embedded ActiveMQ process, but the "common.xml" can easily be modified to support + either a different JMS provider or a standalone ActiveMQ process. In other words, you can split the configuration + so that the inbound and outbound adapters are running in separate JVMs. If you have ActiveMQ installed, simply + modify the "brokerURL" property within the configuration to use "tcp://localhost:61616" for example (instead of + "vm://localhost"). +
\ No newline at end of file