org.springframework.amqp.remoting.service
Class AmqpInvokerServiceExporter

java.lang.Object
  extended by org.springframework.remoting.support.RemotingSupport
      extended by org.springframework.remoting.support.RemoteExporter
          extended by org.springframework.remoting.support.RemoteInvocationBasedExporter
              extended by org.springframework.amqp.remoting.service.AmqpInvokerServiceExporter
All Implemented Interfaces:
MessageListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware

public class AmqpInvokerServiceExporter
extends org.springframework.remoting.support.RemoteInvocationBasedExporter
implements MessageListener

This message listener exposes a plain java service via AMQP. Such services can be accessed via plain AMQP or via AmqpProxyFactoryBean. To configure this message listener so that it actually receives method calls via AMQP, it needs to be put into a listener container. See MessageListener.

When receiving a message, a service method is called according to the contained RemoteInvocation. The result of that invocation is returned as a RemoteInvocationResult contained in a message that is sent according to the ReplyToAddress of the received message.

Please note that this exporter does not use the MessageConverter of the injected AmqpTemplate to convert incoming calls and their results. Instead you have to directly inject the MessageConverter into this class.

This listener responds to "Request/Reply"-style messages as described here.

Since:
1.2

Field Summary
 
Fields inherited from class org.springframework.remoting.support.RemotingSupport
logger
 
Constructor Summary
AmqpInvokerServiceExporter()
           
 
Method Summary
 AmqpTemplate getAmqpTemplate()
           
 MessageConverter getMessageConverter()
           
 void onMessage(Message message)
           
 void setAmqpTemplate(AmqpTemplate amqpTemplate)
          The AMQP template to use for sending the return value.
 void setMessageConverter(MessageConverter messageConverter)
          Set the message converter for this remote service.
 
Methods inherited from class org.springframework.remoting.support.RemoteInvocationBasedExporter
getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor
 
Methods inherited from class org.springframework.remoting.support.RemoteExporter
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface
 
Methods inherited from class org.springframework.remoting.support.RemotingSupport
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmqpInvokerServiceExporter

public AmqpInvokerServiceExporter()
Method Detail

onMessage

public void onMessage(Message message)
Specified by:
onMessage in interface MessageListener

getAmqpTemplate

public AmqpTemplate getAmqpTemplate()

setAmqpTemplate

public void setAmqpTemplate(AmqpTemplate amqpTemplate)
The AMQP template to use for sending the return value.

Note that the exchange and routing key parameters on this template are ignored for these return messages. Instead of those the respective parameters from the original message's returnAddress are being used.

Also, the template's MessageConverter is not used for the reply.

See Also:
setMessageConverter(MessageConverter)

getMessageConverter

public MessageConverter getMessageConverter()

setMessageConverter

public void setMessageConverter(MessageConverter messageConverter)
Set the message converter for this remote service. Used to deserialize remote method calls and to serialize their return values.

The default converter is a SimpleMessageConverter, which is able to handle byte arrays, Strings, and Serializable Objects depending on the message content type header.

Note that this class never uses the message converter of the underlying AmqpTemplate!

See Also:
SimpleMessageConverter