java.lang.Object | |
↳ | org.springframework.jms.remoting.JmsInvokerClientInterceptor |
Known Direct Subclasses |
org.aopalliance.intercept.MethodInterceptor for accessing a JMS-based remote service.
Serializes remote invocation objects and deserializes remote invocation result objects. Uses Java serialization just like RMI, but with the JMS provider as communication infrastructure.
To be configured with a javax.jms.QueueConnectionFactory and a target queue (either as javax.jms.Queue reference or as queue name).
Thanks to James Strachan for the original prototype that this JMS invoker mechanism was inspired by!
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
| |||||||||||
Set the QueueConnectionFactory to use for obtaining JMS QueueConnections.
| |||||||||||
Set the DestinationResolver that is to be used to resolve Queue
references for this accessor.
| |||||||||||
Specify the MessageConverter to use for turning
RemoteInvocation
objects into request messages, as well as response messages into
RemoteInvocationResult objects. | |||||||||||
Set the target Queue to send invoker requests to.
| |||||||||||
Set the name of target queue to send invoker requests to.
| |||||||||||
Set the timeout to use for receiving the response message for a request
(in milliseconds).
| |||||||||||
Set the RemoteInvocationFactory to use for this accessor.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Convert the given JMS invoker access exception to an appropriate
Spring RemoteAccessException.
| |||||||||||
Create a new JMS Connection for this JMS invoker,
ideally a
javax.jms.QueueConnection . | |||||||||||
Create a new RemoteInvocation object for the given AOP method invocation.
| |||||||||||
Create the invoker request message.
| |||||||||||
Create a new JMS Session for this JMS invoker,
ideally a
javax.jms.QueueSession . | |||||||||||
Actually execute the given request, sending the invoker request message
to the specified target queue and waiting for a corresponding response.
| |||||||||||
Execute the given remote invocation, sending an invoker request message
to this accessor's target queue and waiting for a corresponding response.
| |||||||||||
Extract the invocation result from the response message.
| |||||||||||
Return the QueueConnectionFactory to use for obtaining JMS QueueConnections.
| |||||||||||
Return the timeout to use for receiving the response message for a request
(in milliseconds).
| |||||||||||
Callback that is invoked by
extractInvocationResult
when it encounters an invalid response message. | |||||||||||
Recreate the invocation result contained in the given RemoteInvocationResult
object.
| |||||||||||
Resolve this accessor's target queue.
| |||||||||||
Resolve the given queue name into a JMS javax.jms.Queue,
via this accessor's
DestinationResolver . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
|
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
Set the QueueConnectionFactory to use for obtaining JMS QueueConnections.
Set the DestinationResolver that is to be used to resolve Queue references for this accessor.
The default resolver is a DynamicDestinationResolver. Specify a JndiDestinationResolver for resolving destination names as JNDI locations.
Specify the MessageConverter to use for turning
RemoteInvocation
objects into request messages, as well as response messages into
RemoteInvocationResult
objects.
Default is a SimpleMessageConverter
,
using a standard JMS javax.jms.ObjectMessage 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.
Set the target Queue to send invoker requests to.
Set the name of target queue to send invoker requests to.
The specified name will be dynamically resolved via the
DestinationResolver
.
Set the timeout to use for receiving the response message for a request (in milliseconds).
The default is 0, which indicates a blocking receive without timeout.
Set the RemoteInvocationFactory to use for this accessor.
Default is a DefaultRemoteInvocationFactory
.
A custom invocation factory can add further context information to the invocation, for example user credentials.
Convert the given JMS invoker access exception to an appropriate Spring RemoteAccessException.
ex | the exception to convert |
---|
Create a new JMS Connection for this JMS invoker,
ideally a javax.jms.QueueConnection
.
The default implementation uses the
javax.jms.QueueConnectionFactory
API if available,
falling back to a standard JMS 1.1 ConnectionFactory otherwise.
This is necessary for working with generic JMS 1.1 connection pools
(such as ActiveMQ's org.apache.activemq.pool.PooledConnectionFactory
).
JMSException |
---|
Create a new RemoteInvocation object for the given AOP method invocation. The default implementation delegates to the RemoteInvocationFactory.
Can be overridden in subclasses to provide custom RemoteInvocation subclasses, containing additional invocation parameters like user credentials. Note that it is preferable to use a custom RemoteInvocationFactory which is a reusable strategy.
methodInvocation | the current AOP method invocation |
---|
Create the invoker request message.
The default implementation creates a JMS ObjectMessage for the given RemoteInvocation object.
session | the current JMS Session |
---|---|
invocation | the remote invocation to send |
if the message could not be created | |
JMSException |
Create a new JMS Session for this JMS invoker,
ideally a javax.jms.QueueSession
.
The default implementation uses the
javax.jms.QueueConnection
API if available,
falling back to a standard JMS 1.1 Connection otherwise.
This is necessary for working with generic JMS 1.1 connection pools
(such as ActiveMQ's org.apache.activemq.pool.PooledConnectionFactory
).
JMSException |
---|
Actually execute the given request, sending the invoker request message to the specified target queue and waiting for a corresponding response.
The default implementation is based on standard JMS send/receive, using a javax.jms.TemporaryQueue for receiving the response.
session | the JMS Session to use |
---|---|
queue | the resolved target Queue to send to |
requestMessage | the JMS Message to send |
in case of JMS failure | |
JMSException |
Execute the given remote invocation, sending an invoker request message to this accessor's target queue and waiting for a corresponding response.
invocation | the RemoteInvocation to execute |
---|
in case of JMS failure | |
JMSException |
Extract the invocation result from the response message.
The default implementation expects a JMS ObjectMessage carrying
a RemoteInvocationResult object. If an invalid response message is
encountered, the onInvalidResponse
callback gets invoked.
responseMessage | the response message |
---|
is thrown if a JMS exception occurs | |
JMSException |
Return the QueueConnectionFactory to use for obtaining JMS QueueConnections.
Return the timeout to use for receiving the response message for a request (in milliseconds).
Callback that is invoked by extractInvocationResult
when it encounters an invalid response message.
The default implementation throws a MessageFormatException.
responseMessage | the invalid response message |
---|
if the invalid response should lead to an infrastructure exception propagated to the caller | |
JMSException |
Recreate the invocation result contained in the given RemoteInvocationResult object. The default implementation calls the default recreate method.
Can be overridden in subclass to provide custom recreation, potentially processing the returned result object.
result | the RemoteInvocationResult to recreate |
---|
Throwable | if the invocation result is an exception |
---|
Resolve this accessor's target queue.
session | the current JMS Session |
---|
if resolution failed | |
JMSException |
Resolve the given queue name into a JMS javax.jms.Queue,
via this accessor's DestinationResolver
.
session | the current JMS Session |
---|---|
queueName | the name of the queue |
if resolution failed | |
JMSException |