类 JmsInvokerServiceExporter
- java.lang.Object
- org.springframework.remoting.support.RemotingSupport
- org.springframework.remoting.support.RemoteExporter
- org.springframework.remoting.support.RemoteInvocationBasedExporter
- org.springframework.jms.remoting.JmsInvokerServiceExporter
public class JmsInvokerServiceExporter extends RemoteInvocationBasedExporter implements SessionAwareMessageListener<Message>, InitializingBean
JMS message listener that exports the specified service bean as a JMS service endpoint, accessible via a JMS invoker proxy.Note that this class implements Spring's
SessionAwareMessageListener
interface, since it requires access to the active JMS Session. Hence, this class can only be used with message listener containers which support the SessionAwareMessageListener interface (e.g. Spring'sDefaultMessageListenerContainer
).Thanks to James Strachan for the original prototype that this JMS invoker mechanism was inspired by!
- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, James Strachan
- 另请参阅:
JmsInvokerClientInterceptor
,JmsInvokerProxyFactoryBean
字段概要
从类继承的字段 org.springframework.remoting.support.RemotingSupport
logger
构造器概要
构造器 构造器 说明 JmsInvokerServiceExporter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected Message
createResponseMessage(Message request, Session session, RemoteInvocationResult result)
Create the invocation result response message.protected RemoteInvocation
onInvalidRequest(Message requestMessage)
Callback that is invoked byreadRemoteInvocation(javax.jms.Message)
when it encounters an invalid request message.void
onMessage(Message requestMessage, Session session)
Callback for processing a received JMS message.protected RemoteInvocation
readRemoteInvocation(Message requestMessage)
Read a RemoteInvocation from the given JMS message.void
setIgnoreInvalidRequests(boolean ignoreInvalidRequests)
Set whether invalidly formatted messages should be discarded.void
setMessageConverter(MessageConverter messageConverter)
Specify the MessageConverter to use for turning request messages intoRemoteInvocation
objects, as well asRemoteInvocationResult
objects into response messages.protected void
writeRemoteInvocationResult(Message requestMessage, Session session, RemoteInvocationResult result)
Send the given RemoteInvocationResult as a JMS message to the originator.从类继承的方法 org.springframework.remoting.support.RemoteInvocationBasedExporter
getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor
从类继承的方法 org.springframework.remoting.support.RemoteExporter
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, setInterceptors, setRegisterTraceInterceptor, setService, setServiceInterface
从类继承的方法 org.springframework.remoting.support.RemotingSupport
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
构造器详细资料
JmsInvokerServiceExporter
public JmsInvokerServiceExporter()
方法详细资料
setMessageConverter
public void setMessageConverter(@Nullable MessageConverter messageConverter)
Specify the MessageConverter to use for turning request messages intoRemoteInvocation
objects, as well asRemoteInvocationResult
objects into response messages.Default is a
SimpleMessageConverter
, using a standard JMSObjectMessage
for each invocation / invocation result object.Custom implementations may generally adapt Serializables into special kinds of messages, or might be specifically tailored for translating RemoteInvocation(Result)s into specific kinds of messages.
setIgnoreInvalidRequests
public void setIgnoreInvalidRequests(boolean ignoreInvalidRequests)
Set whether invalidly formatted messages should be discarded. Default is "true".Switch this flag to "false" to throw an exception back to the listener container. This will typically lead to redelivery of the message, which is usually undesirable - since the message content will be the same (that is, still invalid).
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
onMessage
public void onMessage(Message requestMessage, Session session) throws JMSException
从接口复制的说明:SessionAwareMessageListener
Callback for processing a received JMS message.Implementors are supposed to process the given Message, typically sending reply messages through the given Session.
- 指定者:
onMessage
在接口中SessionAwareMessageListener<Message>
- 参数:
requestMessage
- the received JMS message (nevernull
)session
- the underlying JMS Session (nevernull
)- 抛出:
JMSException
- if thrown by JMS methods
readRemoteInvocation
@Nullable protected RemoteInvocation readRemoteInvocation(Message requestMessage) throws JMSException
Read a RemoteInvocation from the given JMS message.- 参数:
requestMessage
- current request message- 返回:
- the RemoteInvocation object (or
null
in case of an invalid message that will simply be ignored) - 抛出:
JMSException
- in case of message access failure
writeRemoteInvocationResult
protected void writeRemoteInvocationResult(Message requestMessage, Session session, RemoteInvocationResult result) throws JMSException
Send the given RemoteInvocationResult as a JMS message to the originator.- 参数:
requestMessage
- current request messagesession
- the JMS Session to useresult
- the RemoteInvocationResult object- 抛出:
JMSException
- if thrown by trying to send the message
createResponseMessage
protected Message createResponseMessage(Message request, Session session, RemoteInvocationResult result) throws JMSException
Create the invocation result response message.The default implementation creates a JMS ObjectMessage for the given RemoteInvocationResult object. It sets the response's correlation id to the request message's correlation id, if any; otherwise to the request message id.
- 参数:
request
- the original request messagesession
- the JMS session to useresult
- the invocation result- 返回:
- the message response to send
- 抛出:
JMSException
- if creating the message failed
onInvalidRequest
@Nullable protected RemoteInvocation onInvalidRequest(Message requestMessage) throws JMSException
Callback that is invoked byreadRemoteInvocation(javax.jms.Message)
when it encounters an invalid request message.The default implementation either discards the invalid message or throws a MessageFormatException - according to the "ignoreInvalidRequests" flag, which is set to "true" (that is, discard invalid messages) by default.
- 参数:
requestMessage
- the invalid request message- 返回:
- the RemoteInvocation to expose for the invalid request (typically
null
in case of an invalid message that will simply be ignored) - 抛出:
JMSException
- in case of the invalid request supposed to lead to an exception (instead of ignoring it)- 另请参阅:
readRemoteInvocation(javax.jms.Message)
,setIgnoreInvalidRequests(boolean)