public class AmqpInvokerServiceExporter extends org.springframework.remoting.support.RemoteInvocationBasedExporter implements MessageListener
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.
Constructor and Description |
---|
AmqpInvokerServiceExporter() |
Modifier and Type | Method and Description |
---|---|
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.
|
getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface
public void onMessage(Message message)
onMessage
in interface MessageListener
public AmqpTemplate getAmqpTemplate()
public void setAmqpTemplate(AmqpTemplate amqpTemplate)
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.
amqpTemplate
- The amqp template.setMessageConverter(MessageConverter)
public MessageConverter getMessageConverter()
public void setMessageConverter(MessageConverter messageConverter)
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
!
messageConverter
- The message converter.SimpleMessageConverter