user1224036
user1224036

Reputation: 1008

spring integration jms components understading

I am relatively new to spring integration and working on JMS adapter project, i am trying to understand various adapters. Please can someone explain, why and when to use the following

<bean id="jmsDestination" class="com.tibco.tibjms.TibjmsQueue">
    <constructor-arg value="queue.sample" />
</bean>

this acts as a queue ?

<integration:channel id="requests"/> what is this ? why and when we should define and use with what?

<int-jms:outbound-channel-adapter> and <int-jms:inbound-channel-adapter> when and why we should use this? note, i understand from the documentation one is the consumer and other is creates a new message to the channel.

And finally, <int-jms:message-driven-adapter> when and why we should we use this?

I can go through the documentation, understand each one of this, but cant figure out the sequence in which spring integration code has been written so that i can wire them together.

For example: Answers in the form, "you need to define a channel, and then it should have a outbound adapter withe destination name matching channel id.etc etc. would be of great help"

Thanks for the help in advance.

Upvotes: 0

Views: 1186

Answers (1)

Gary Russell
Gary Russell

Reputation: 174484

Spring Integration is an implementation of Enterprise Integration Patterns.

A Message Channel binds producers to consumers. The most common type is a DirectChannel which is the one you define above.

Your first <bean/> is nothing to do with Spring Integration, it's Tibco's implementation of a JMS Destination (in this case a queue called queue.sample). It's unfortunate that JMS chose 'destination' because you don't just send to destinations, you receive from them too.

The Spring Integration adapters (and Spring JMS on which it sits) sends messages to, and receives messages from, JMS destinations. The destination is part of the adapter configuration.

The outbound-channel-adapter is used to send messages to JMS. There are two types of inbound channel adapter, the inbound-channel-adapter is a polled message source - you configure a poller to run every so often and it calls the adapter to 'poll' for a message; the poller usually blocks in the client for a configurable timeout. The message-driven-channel-adapter is not polled; it has (one or more) internal threads that are event driven - a message is pushed to the adapter's channel when it arrives in the queue.

Of the two, the message-driven adapter is most commonly used, but you may want to use a polled adapter if you want messages to be retrieved only at certain times during the day (using a cron trigger).

A typical flow might be

message-driven-adapter->transformer->outbound-channel-adapter

Where -> are channels, the transformer does some manipulation of the data, and the adapters would be configured to read from and write to destinations.

I suggest you read the introductory and JMS chapters of the Reference Manual.

Upvotes: 2

Related Questions