Class JmsInvokerClientInterceptor

  • java.lang.Object
    • org.springframework.jms.remoting.JmsInvokerClientInterceptor
    • Constructor Detail

      • JmsInvokerClientInterceptor

        public JmsInvokerClientInterceptor()
    • Method Detail

      • setConnectionFactory

        public void setConnectionFactory(@Nullable
                                         ConnectionFactory connectionFactory)
        Set the QueueConnectionFactory to use for obtaining JMS QueueConnections.
      • getConnectionFactory

        protected ConnectionFactory getConnectionFactory()
        Return the QueueConnectionFactory to use for obtaining JMS QueueConnections.
      • setQueue

        public void setQueue(Queue queue)
        Set the target Queue to send invoker requests to.
      • setQueueName

        public void setQueueName(java.lang.String queueName)
        Set the name of target queue to send invoker requests to.

        The specified name will be dynamically resolved via the DestinationResolver.

      • setDestinationResolver

        public void setDestinationResolver(@Nullable
                                           DestinationResolver destinationResolver)
        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.

        See Also:
        DynamicDestinationResolver, JndiDestinationResolver
      • setMessageConverter

        public void setMessageConverter(@Nullable
                                        MessageConverter messageConverter)
        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 ObjectMessage for each invocation / invocation result object.

        Custom implementations may generally adapt Serializable objects into special kinds of messages, or might be specifically tailored for translating RemoteInvocation(Result)s into specific kinds of messages.

      • setReceiveTimeout

        public void setReceiveTimeout(long receiveTimeout)
        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.

        See Also:
        MessageConsumer.receive(long), MessageConsumer.receive()
      • getReceiveTimeout

        protected long getReceiveTimeout()
        Return the timeout to use for receiving the response message for a request (in milliseconds).
      • afterPropertiesSet

        public void afterPropertiesSet()
        Description copied from interface: InitializingBean
        Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, 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.

        Specified by:
        afterPropertiesSet in interface InitializingBean
      • invoke

        public java.lang.Object invoke(MethodInvocation methodInvocation)
                                          throws java.lang.Throwable
        Description copied from interface: MethodInterceptor
        Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invoke Joinpoint.proceed().
        Specified by:
        invoke in interface MethodInterceptor
        methodInvocation - the method invocation joinpoint
        the result of the call to Joinpoint.proceed(); might be intercepted by the interceptor
        java.lang.Throwable - if the interceptors or the target object throws an exception
      • resolveQueue

        protected Queue resolveQueue(Session session)
                              throws JMSException
        Resolve this accessor's target queue.
        session - the current JMS Session
        the resolved target Queue
        JMSException - if resolution failed
      • createRequestMessage

        protected Message createRequestMessage(Session session,
                                               RemoteInvocation invocation)
                                        throws JMSException
        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
        the JMS Message to send
        JMSException - if the message could not be created
      • doExecuteRequest

        protected Message doExecuteRequest(Session session,
                                                     Queue queue,
                                                     Message requestMessage)
                                              throws 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 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
        the RemoteInvocationResult object
        JMSException - in case of JMS failure
      • recreateRemoteInvocationResult

        protected java.lang.Object recreateRemoteInvocationResult(RemoteInvocationResult result)
                                                                     throws java.lang.Throwable
        Recreate the invocation result contained in the given RemoteInvocationResult object.

        The default implementation calls the default recreate() method.

        Can be overridden in subclasses to provide custom recreation, potentially processing the returned result object.

        result - the RemoteInvocationResult to recreate
        a return value if the invocation result is a successful return
        java.lang.Throwable - if the invocation result is an exception
        See Also:
      • convertJmsInvokerAccessException

        protected RemoteAccessException convertJmsInvokerAccessException(JMSException ex)
        Convert the given JMS invoker access exception to an appropriate Spring RemoteAccessException.
        ex - the exception to convert
        the RemoteAccessException to throw