org.springframework.integration.gateway
Class SimpleMessagingGateway

java.lang.Object
  extended by org.springframework.integration.gateway.MessagingGatewaySupport
      extended by org.springframework.integration.gateway.SimpleMessagingGateway
All Implemented Interfaces:
MessageBusAware, MessagingGateway
Direct Known Subclasses:
AbstractRemotingGateway, GatewayProxyFactoryBean, JmsGateway

public class SimpleMessagingGateway
extends MessagingGatewaySupport
implements MessagingGateway, MessageBusAware

A general purpose class that supports a variety of message exchanges. Useful for connecting application code to MessageChannels for sending, receiving, or request-reply operations. The sending methods accept any Object as the parameter value (i.e. it is not required to be a Message). A custom MessageCreator may be provided for creating Messages from the Objects. Likewise return values may be any Object and a custom implementation of the MessageMapper strategy may be provided for mapping a reply Message to an Object.

Author:
Mark Fisher

Field Summary
private  EndpointRegistry endpointRegistry
           
private  MessageCreator messageCreator
           
private  MessageMapper messageMapper
           
private  PollableChannel replyChannel
           
private  int replyMapCapacity
           
private  ReplyMessageCorrelator replyMessageCorrelator
           
private  java.lang.Object replyMessageCorrelatorMonitor
           
private  long replyTimeout
           
private  MessageChannel requestChannel
           
 
Constructor Summary
SimpleMessagingGateway()
           
SimpleMessagingGateway(MessageChannel requestChannel)
           
 
Method Summary
 java.lang.Object receive()
           
 void receiveAndForward()
           
private  void registerReplyMessageCorrelator()
           
 void send(java.lang.Object object)
           
 java.lang.Object sendAndReceive(java.lang.Object object)
           
private  java.lang.Object sendAndReceive(java.lang.Object object, boolean shouldMapMessage)
           
private  Message<?> sendAndReceiveMessage(Message<?> message)
           
 Message<?> sendAndReceiveMessage(java.lang.Object object)
           
private  Message<?> sendAndReceiveWithReplyMessageCorrelator(Message<?> message)
           
 void setMessageBus(MessageBus messageBus)
           
 void setMessageCreator(MessageCreator<?,?> messageCreator)
           
 void setMessageMapper(MessageMapper<?,?> messageMapper)
           
 void setReplyChannel(PollableChannel replyChannel)
          Set the reply channel.
 void setReplyMapCapacity(int replyMapCapacity)
          Set the max capacity for the map that is used to store replies until requested by the correlationId.
 void setReplyTimeout(long replyTimeout)
          Set the timeout value for receiving reply messages.
 void setRequestChannel(MessageChannel requestChannel)
          Set the request channel.
 
Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
getMessageExchangeTemplate, setRequestTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestChannel

private volatile MessageChannel requestChannel

replyChannel

private volatile PollableChannel replyChannel

replyTimeout

private volatile long replyTimeout

replyMapCapacity

private volatile int replyMapCapacity

messageCreator

private volatile MessageCreator messageCreator

messageMapper

private volatile MessageMapper messageMapper

replyMessageCorrelator

private volatile ReplyMessageCorrelator replyMessageCorrelator

endpointRegistry

private volatile EndpointRegistry endpointRegistry

replyMessageCorrelatorMonitor

private final java.lang.Object replyMessageCorrelatorMonitor
Constructor Detail

SimpleMessagingGateway

public SimpleMessagingGateway(MessageChannel requestChannel)

SimpleMessagingGateway

public SimpleMessagingGateway()
Method Detail

setRequestChannel

public void setRequestChannel(MessageChannel requestChannel)
Set the request channel.

Parameters:
requestChannel - the channel to which request messages will be sent

setReplyChannel

public void setReplyChannel(PollableChannel replyChannel)
Set the reply channel. If no reply channel is provided, this template will always use an anonymous, temporary channel for handling replies.

Parameters:
replyChannel - the channel from which reply messages will be received

setReplyMapCapacity

public void setReplyMapCapacity(int replyMapCapacity)
Set the max capacity for the map that is used to store replies until requested by the correlationId. The default value is 100.


setMessageCreator

public void setMessageCreator(MessageCreator<?,?> messageCreator)

setMessageMapper

public void setMessageMapper(MessageMapper<?,?> messageMapper)

setMessageBus

public void setMessageBus(MessageBus messageBus)
Specified by:
setMessageBus in interface MessageBusAware

setReplyTimeout

public void setReplyTimeout(long replyTimeout)
Description copied from class: MessagingGatewaySupport
Set the timeout value for receiving reply messages. If not explicitly configured, the default is an indefinite timeout.

Overrides:
setReplyTimeout in class MessagingGatewaySupport
Parameters:
replyTimeout - the timeout value in milliseconds

send

public void send(java.lang.Object object)
Specified by:
send in interface MessagingGateway

receive

public java.lang.Object receive()
Specified by:
receive in interface MessagingGateway

receiveAndForward

public void receiveAndForward()
Specified by:
receiveAndForward in interface MessagingGateway

sendAndReceive

public java.lang.Object sendAndReceive(java.lang.Object object)
Specified by:
sendAndReceive in interface MessagingGateway

sendAndReceiveMessage

public Message<?> sendAndReceiveMessage(java.lang.Object object)
Specified by:
sendAndReceiveMessage in interface MessagingGateway

sendAndReceive

private java.lang.Object sendAndReceive(java.lang.Object object,
                                        boolean shouldMapMessage)

sendAndReceiveMessage

private Message<?> sendAndReceiveMessage(Message<?> message)

sendAndReceiveWithReplyMessageCorrelator

private Message<?> sendAndReceiveWithReplyMessageCorrelator(Message<?> message)

registerReplyMessageCorrelator

private void registerReplyMessageCorrelator()