接口 JmsOperations

  • 所有已知实现类:
    JmsTemplate

    public interface JmsOperations
    Specifies a basic set of JMS operations.

    Implemented by JmsTemplate. Not often used but a useful option to enhance testability, as it can easily be mocked or stubbed.

    Provides JmsTemplate'ssend(..) and receive(..) methods that mirror various JMS API methods. See the JMS specification and javadocs for details on those methods.

    Provides also basic request reply operation using a temporary queue to collect the reply.

    从以下版本开始:
    1.1
    作者:
    Mark Pollack, Juergen Hoeller, Stephane Nicoll
    另请参阅:
    JmsTemplate, Destination, Session, MessageProducer, MessageConsumer
    • 方法详细资料

      • execute

        <T> T execute​(SessionCallback<T> action)
               throws JmsException
        Execute the action specified by the given action object within a JMS Session.
        参数:
        action - callback object that exposes the session
        返回:
        the result object from working with the session
        抛出:
        JmsException - if there is any problem
      • execute

        <T> T execute​(ProducerCallback<T> action)
               throws JmsException
        Send messages to the default JMS destination (or one specified for each send operation). The callback gives access to the JMS Session and MessageProducer in order to perform complex send operations.
        参数:
        action - callback object that exposes the session/producer pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • execute

        <T> T execute​(Destination destination,
                      ProducerCallback<T> action)
               throws JmsException
        Send messages to a JMS destination. The callback gives access to the JMS Session and MessageProducer in order to perform complex send operations.
        参数:
        destination - the destination to send messages to
        action - callback object that exposes the session/producer pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • execute

        <T> T execute​(String destinationName,
                      ProducerCallback<T> action)
               throws JmsException
        Send messages to a JMS destination. The callback gives access to the JMS Session and MessageProducer in order to perform complex send operations.
        参数:
        destinationName - the name of the destination to send messages to (to be resolved to an actual destination by a DestinationResolver)
        action - callback object that exposes the session/producer pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • send

        void send​(MessageCreator messageCreator)
           throws JmsException
        Send a message to the default destination.

        This will only work with a default destination specified!

        参数:
        messageCreator - callback to create a message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • send

        void send​(Destination destination,
                  MessageCreator messageCreator)
           throws JmsException
        Send a message to the specified destination. The MessageCreator callback creates the message given a Session.
        参数:
        destination - the destination to send this message to
        messageCreator - callback to create a message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • send

        void send​(String destinationName,
                  MessageCreator messageCreator)
           throws JmsException
        Send a message to the specified destination. The MessageCreator callback creates the message given a Session.
        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        messageCreator - callback to create a message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • convertAndSend

        void convertAndSend​(Object message)
                     throws JmsException
        Send the given object to the default destination, converting the object to a JMS message with a configured MessageConverter.

        This will only work with a default destination specified!

        参数:
        message - the object to convert to a message
        抛出:
        JmsException - converted checked JMSException to unchecked
      • convertAndSend

        void convertAndSend​(Destination destination,
                            Object message)
                     throws JmsException
        Send the given object to the specified destination, converting the object to a JMS message with a configured MessageConverter.
        参数:
        destination - the destination to send this message to
        message - the object to convert to a message
        抛出:
        JmsException - converted checked JMSException to unchecked
      • convertAndSend

        void convertAndSend​(String destinationName,
                            Object message)
                     throws JmsException
        Send the given object to the specified destination, converting the object to a JMS message with a configured MessageConverter.
        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        message - the object to convert to a message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • convertAndSend

        void convertAndSend​(Object message,
                            MessagePostProcessor postProcessor)
                     throws JmsException
        Send the given object to the default destination, converting the object to a JMS message with a configured MessageConverter. The MessagePostProcessor callback allows for modification of the message after conversion.

        This will only work with a default destination specified!

        参数:
        message - the object to convert to a message
        postProcessor - the callback to modify the message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • convertAndSend

        void convertAndSend​(Destination destination,
                            Object message,
                            MessagePostProcessor postProcessor)
                     throws JmsException
        Send the given object to the specified destination, converting the object to a JMS message with a configured MessageConverter. The MessagePostProcessor callback allows for modification of the message after conversion.
        参数:
        destination - the destination to send this message to
        message - the object to convert to a message
        postProcessor - the callback to modify the message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • convertAndSend

        void convertAndSend​(String destinationName,
                            Object message,
                            MessagePostProcessor postProcessor)
                     throws JmsException
        Send the given object to the specified destination, converting the object to a JMS message with a configured MessageConverter. The MessagePostProcessor callback allows for modification of the message after conversion.
        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        message - the object to convert to a message.
        postProcessor - the callback to modify the message
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receive

        Message receive()
                 throws JmsException
        Receive a message synchronously from the default destination, but only wait up to a specified time for delivery.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        This will only work with a default destination specified!

        返回:
        the message received by the consumer, or null if the timeout expires
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receive

        Message receive​(Destination destination)
                 throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destination - the destination to receive a message from
        返回:
        the message received by the consumer, or null if the timeout expires
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receive

        Message receive​(String destinationName)
                 throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        返回:
        the message received by the consumer, or null if the timeout expires
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveSelected

        Message receiveSelected​(String messageSelector)
                         throws JmsException
        Receive a message synchronously from the default destination, but only wait up to a specified time for delivery.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        This will only work with a default destination specified!

        参数:
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        返回:
        the message received by the consumer, or null if the timeout expires
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveSelected

        Message receiveSelected​(Destination destination,
                                String messageSelector)
                         throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destination - the destination to receive a message from
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        返回:
        the message received by the consumer, or null if the timeout expires
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveSelected

        Message receiveSelected​(String destinationName,
                                String messageSelector)
                         throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        返回:
        the message received by the consumer, or null if the timeout expires
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveAndConvert

        Object receiveAndConvert()
                          throws JmsException
        Receive a message synchronously from the default destination, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        This will only work with a default destination specified!

        返回:
        the message produced for the consumer or null if the timeout expires.
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveAndConvert

        Object receiveAndConvert​(Destination destination)
                          throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destination - the destination to receive a message from
        返回:
        the message produced for the consumer or null if the timeout expires.
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveAndConvert

        Object receiveAndConvert​(String destinationName)
                          throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        返回:
        the message produced for the consumer or null if the timeout expires.
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveSelectedAndConvert

        Object receiveSelectedAndConvert​(String messageSelector)
                                  throws JmsException
        Receive a message synchronously from the default destination, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        This will only work with a default destination specified!

        参数:
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        返回:
        the message produced for the consumer or null if the timeout expires.
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveSelectedAndConvert

        Object receiveSelectedAndConvert​(Destination destination,
                                         String messageSelector)
                                  throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destination - the destination to receive a message from
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        返回:
        the message produced for the consumer or null if the timeout expires.
        抛出:
        JmsException - checked JMSException converted to unchecked
      • receiveSelectedAndConvert

        Object receiveSelectedAndConvert​(String destinationName,
                                         String messageSelector)
                                  throws JmsException
        Receive a message synchronously from the specified destination, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

        This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        返回:
        the message produced for the consumer or null if the timeout expires.
        抛出:
        JmsException - checked JMSException converted to unchecked
      • sendAndReceive

        Message sendAndReceive​(MessageCreator messageCreator)
                        throws JmsException
        Send a request message and receive the reply from a default destination. The MessageCreator callback creates the message given a Session. A temporary queue is created as part of this operation and is set in the JMSReplyTO header of the message.

        This will only work with a default destination specified!

        参数:
        messageCreator - callback to create a request message
        返回:
        the reply, possibly null if the message could not be received, for example due to a timeout
        抛出:
        JmsException - checked JMSException converted to unchecked
        从以下版本开始:
        4.1
      • sendAndReceive

        Message sendAndReceive​(Destination destination,
                               MessageCreator messageCreator)
                        throws JmsException
        Send a message and receive the reply from the specified destination. The MessageCreator callback creates the message given a Session. A temporary queue is created as part of this operation and is set in the JMSReplyTO header of the message.
        参数:
        destination - the destination to send this message to
        messageCreator - callback to create a message
        返回:
        the reply, possibly null if the message could not be received, for example due to a timeout
        抛出:
        JmsException - checked JMSException converted to unchecked
        从以下版本开始:
        4.1
      • sendAndReceive

        Message sendAndReceive​(String destinationName,
                               MessageCreator messageCreator)
                        throws JmsException
        Send a message and receive the reply from the specified destination. The MessageCreator callback creates the message given a Session. A temporary queue is created as part of this operation and is set in the JMSReplyTO header of the message.
        参数:
        destinationName - the name of the destination to send this message to (to be resolved to an actual destination by a DestinationResolver)
        messageCreator - callback to create a message
        返回:
        the reply, possibly null if the message could not be received, for example due to a timeout
        抛出:
        JmsException - checked JMSException converted to unchecked
        从以下版本开始:
        4.1
      • browse

        <T> T browse​(BrowserCallback<T> action)
              throws JmsException
        Browse messages in the default JMS queue. The callback gives access to the JMS Session and QueueBrowser in order to browse the queue and react to the contents.
        参数:
        action - callback object that exposes the session/browser pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • browse

        <T> T browse​(Queue queue,
                     BrowserCallback<T> action)
              throws JmsException
        Browse messages in a JMS queue. The callback gives access to the JMS Session and QueueBrowser in order to browse the queue and react to the contents.
        参数:
        queue - the queue to browse
        action - callback object that exposes the session/browser pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • browse

        <T> T browse​(String queueName,
                     BrowserCallback<T> action)
              throws JmsException
        Browse messages in a JMS queue. The callback gives access to the JMS Session and QueueBrowser in order to browse the queue and react to the contents.
        参数:
        queueName - the name of the queue to browse (to be resolved to an actual destination by a DestinationResolver)
        action - callback object that exposes the session/browser pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • browseSelected

        <T> T browseSelected​(String messageSelector,
                             BrowserCallback<T> action)
                      throws JmsException
        Browse selected messages in a JMS queue. The callback gives access to the JMS Session and QueueBrowser in order to browse the queue and react to the contents.
        参数:
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        action - callback object that exposes the session/browser pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • browseSelected

        <T> T browseSelected​(Queue queue,
                             String messageSelector,
                             BrowserCallback<T> action)
                      throws JmsException
        Browse selected messages in a JMS queue. The callback gives access to the JMS Session and QueueBrowser in order to browse the queue and react to the contents.
        参数:
        queue - the queue to browse
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        action - callback object that exposes the session/browser pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked
      • browseSelected

        <T> T browseSelected​(String queueName,
                             String messageSelector,
                             BrowserCallback<T> action)
                      throws JmsException
        Browse selected messages in a JMS queue. The callback gives access to the JMS Session and QueueBrowser in order to browse the queue and react to the contents.
        参数:
        queueName - the name of the queue to browse (to be resolved to an actual destination by a DestinationResolver)
        messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
        action - callback object that exposes the session/browser pair
        返回:
        the result object from working with the session
        抛出:
        JmsException - checked JMSException converted to unchecked