The Spring Integration framework provides good support for integrating Spring applications with Java Messaging Service (JMS).
If you are new to JMS, I would recommend reading my Just Spring book that explains the concepts of JMS at a high level.
The framework provides inbound and outbound adapters for receiving
and sending messages across to external messaging systems. The inbound
adapters will pick up a message from a JMS destination (
queue) and publish them onto local channels. On
the other hand, the outbound adapters will convert a local payload from a
channel into JMS Message and publish to a JMS destination (
jms namespace defines the
relevant elements to use these adapters declaratively.
Receiving messages from a messaging system may involve some complexity. This is due to the fact that the consumption might be driven by the consumer client or by the provider. In the former case, the client will have to poll for messages on a regular basis, while the latter case ensures that the client is given a message when it arrives on a server (hence message-driven or event-driven).
As explained, the
inbound-channel-adapter is responsible for
receiving messages from a JMS Server. The endpoint is configured to
connect to a JMS Server, fetch the messages, and publish them onto a
local channel. Note that this is a polling consumer. In the backend,
it uses the
JmsTemplate's receive method to poll ...