org.springframework.jms.remoting

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

        @Nullable
        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

        @Nullable
        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
        Parameters:
        methodInvocation - the method invocation joinpoint
        Returns:
        the result of the call to Joinpoint.proceed(); might be intercepted by the interceptor
        Throws:
        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.
        Parameters:
        session - the current JMS Session
        Returns:
        the resolved target Queue
        Throws:
        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.

        Parameters:
        session - the current JMS Session
        invocation - the remote invocation to send
        Returns:
        the JMS Message to send
        Throws:
        JMSException - if the message could not be created
      • doExecuteRequest

        @Nullable
        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.

        Parameters:
        session - the JMS Session to use
        queue - the resolved target Queue to send to
        requestMessage - the JMS Message to send
        Returns:
        the RemoteInvocationResult object
        Throws:
        JMSException - in case of JMS failure
      • recreateRemoteInvocationResult

        @Nullable
        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.

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

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