Class JmsMethods


  • public final class JmsMethods
    extends Object
    Provides methods for publishing and responding to Messages.
    • Constructor Detail

      • JmsMethods

        @Autowired
        JmsMethods​(io.toro.martini.jms.JmsPublisher.Factory jmsPublisherFactory)
    • Method Detail

      • publishTo

        public static void publishTo​(Serializable obj,
                                     String destinationName)
                              throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world!'
         serializable.publishTo('queue://com.torocloud.example.HelloQueue')
         

        Parameters:
        obj - the object to send
        destinationName - the name of the queue/topic to send the object to
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(Serializable obj,
                                     String destinationName,
                                     Closure replyClosure)
                              throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world!'
         serializable.publishTo('queue://com.torocloud.example.HelloQueue') {
             message -> println "Received a reply: ${message}"
         }
         

        Parameters:
        obj - the object to send
        destinationName - the name of the queue/topic to send the object to
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(Serializable obj,
                                     String destinationName,
                                     Map<String,​Object> properties)
                              throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world!'
         serializable.publishTo('queue://com.torocloud.example.HelloQueue', [ "property": "value" ])
         
        Parameters:
        obj - the object to send
        destinationName - the name of the queue/topic to send the object to
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(String string,
                                     String destinationName)
                              throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'Hello, world!'.publishTo( 'queue://com.torocloud.example.HelloQueue' )
         
        Parameters:
        string - the string to send
        destinationName - the name of the queue/topic to send the object to
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(String string,
                                     String destinationName,
                                     Map properties)
                              throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'Hello, world'.publishTo('queue://com.torocloud.example.HelloQueue', [ "property": "value" ])
         

        Parameters:
        string - the string to send
        destinationName - the name of the queue/topic to send the object to
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(String string,
                                     String destinationName,
                                     Closure replyClosure)
                              throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'queue://com.torocloud.example.HelloQueue'.publishString( 'Hello, world!' ){
             println "Received a reply: ${message}"
         }
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        string - the string to send
        Throws:
        JMSException
      • publishTo

        public static void publishTo​(byte[] bytes,
                                     String destinationName)
                              throws JMSException

        Send a string to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         bytes.publishTo( 'queue://com.torocloud.example.BytesQueue' )
         

        Parameters:
        bytes - the array of bytes to send
        destinationName - the name of the queue/topic to send the object to
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(byte[] bytes,
                                     String destinationName,
                                     Map properties)
                              throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         bytes.publishTo( 'queue://com.torocloud.example.BytesQueue' )
         

        Parameters:
        bytes - the array of bytes to send
        destinationName - the name of the queue/topic to send the object to
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • publishTo

        public static void publishTo​(byte[] bytes,
                                     String destinationName,
                                     Closure replyClosure)
                              throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         bytes.publishTo( 'queue://com.torocloud.example.BytesQueue') {
             message -> println "Received a reply: ${message}"
         }
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        bytes - the array of bytes to send
        Throws:
        JMSException
      • publishObject

        public static void publishObject​(String destinationName,
                                         Serializable obj,
                                         Map<String,​Object> properties)
                                  throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world!'
         'queue://com.torocloud.example.HelloQueue'.publishObject(serializable, [ "property": "value" ])
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        obj - the object to send
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
      • publishObject

        public static void publishObject​(String destinationName,
                                         Serializable obj)
                                  throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         'queue://com.torocloud.example.HelloQueue'.publishObject('Hello, world')
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        obj - the object to send
        Throws:
        JMSException
      • publishObject

        public static void publishObject​(String destinationName,
                                         Serializable obj,
                                         Closure replyClosure)
                                  throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         'queue://com.torocloud.example.HelloQueue'.publishObject('Hello, world') {
             message -> println "Received a reply: ${message}"
         }
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        obj - the object to send
        Throws:
        JMSException
      • publishString

        public static void publishString​(String destinationName,
                                         String string)
                                  throws JMSException

        Send a string to the JMS broker.

        Example usage:

             'queue://com.torocloud.example.HelloQueue'.publishString('Hello, world')
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        string - the string to send
        Throws:
        JMSException
      • publishString

        public static void publishString​(String destinationName,
                                         String string,
                                         Closure replyClosure)
                                  throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'queue://com.torocloud.example.HelloQueue'.publishString('Hello, world') {
             message -> println "Received a reply: ${message}"
         }
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        string - the string to send
        Throws:
        JMSException
      • publishString

        public static void publishString​(String destinationName,
                                         String string,
                                         Map<String,​Object> properties)
                                  throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'queue://com.torocloud.example.HelloQueue'.publishString('Hello, world', [ 'property': 'value' ])
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        string - the string to send
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
      • publishBytes

        public static void publishBytes​(String destinationName,
                                        byte[] bytes)
                                 throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         'queue://com.torocloud.example.BytesQueue'.publishBytes( bytes )
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        bytes - the array of bytes to send
        Throws:
        JMSException
      • publishBytes

        public static void publishBytes​(String destinationName,
                                        byte[] bytes,
                                        Closure replyClosure)
                                 throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         'queue://com.torocloud.example.BytesQueue'.publishBytes( bytes ) {
             message -> println "Received a reply: ${message}"
         }
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        bytes - the array of bytes to send
        Throws:
        JMSException
      • publishBytes

        public static void publishBytes​(String destinationName,
                                        byte[] bytes,
                                        Map<String,​Object> properties)
                                 throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         'queue://com.torocloud.example.BytesQueue'.publishBytes( bytes, [ 'property': 'value' ] )
         

        Parameters:
        destinationName - the name of the queue/topic to send the object to
        bytes - the array of bytes to send
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
      • replyTo

        public static void replyTo​(Serializable obj,
                                   Message requestMessage)
                            throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world'
         serializable.replyTo( message )
         

        Parameters:
        obj - the object to send
        requestMessage - the message to reply to
        Throws:
        JMSException
        Since:
        1.0
      • replyTo

        public static void replyTo​(Serializable obj,
                                   Message requestMessage,
                                   Map<String,​Object> properties)
                            throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         'Hello, world'.replyTo( message, properties )
         

        Parameters:
        obj - the object to send
        requestMessage - the message to reply to
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • replyTo

        public static void replyTo​(String string,
                                   Message requestMessage)
                            throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'Hello, world'.publishTo( message )
         

        Parameters:
        string - the string to send
        requestMessage - the message to reply to
        Throws:
        JMSException
        Since:
        1.0
      • replyTo

        public static void replyTo​(String string,
                                   Message requestMessage,
                                   Map<String,​Object> properties)
                            throws JMSException

        Send a string to the JMS broker.

        Example usage:

         'Hello, world'.replyTo( message, [ 'property': 'value' ] )
         

        Parameters:
        string - the string to send
        requestMessage - the message to reply to
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • replyTo

        public static void replyTo​(byte[] bytes,
                                   Message requestMessage)
                            throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         bytes.replyTo( message )
         

        Parameters:
        bytes - the array of bytes to send
        requestMessage - the message to reply to
        Throws:
        JMSException
        Since:
        1.0
      • replyTo

        public static void replyTo​(byte[] bytes,
                                   Message requestMessage,
                                   Map<String,​Object> properties)
                            throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         bytes.replyTo( message, [ 'property': 'value' ] )
         

        Parameters:
        bytes - the array of bytes to send
        requestMessage - the message to reply to
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • replyWith

        public static void replyWith​(Message requestMessage,
                                     Serializable obj)
                              throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world'
         message.replyWith( serializable )
         

        Parameters:
        requestMessage - the message to reply to
        obj - the object to send
        Throws:
        JMSException
        Since:
        1.0
      • replyWith

        public static void replyWith​(Message requestMessage,
                                     Serializable obj,
                                     Map<String,​Object> properties)
                              throws JMSException

        Send a serializable object to the JMS broker.

        Example usage:

         Serializable serializable = 'Hello, world'
         message.replyWith( serializable, [ 'property' : 'value' ] )
         

        Parameters:
        requestMessage - the message to reply to
        obj - the object to send
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
        Since:
        1.0
      • replyWith

        public static void replyWith​(Message requestMessage,
                                     String string)
                              throws JMSException

        Send a string to the JMS broker.

        Example usage:

         message.replyWith( 'Hello, world' )
         

        Parameters:
        requestMessage - the message to reply to
        string - the string to send
        Throws:
        JMSException
        Since:
        1.0
      • replyWith

        public static void replyWith​(Message requestMessage,
                                     String string,
                                     Map<String,​Object> properties)
                              throws JMSException

        Send a string to the JMS broker.

        Example usage:

         message.replyWith( 'Hello, world', [ 'property': 'value' ] )
         

        Parameters:
        requestMessage - the message to reply to
        string - the string to send
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
      • replyWith

        public static void replyWith​(Message requestMessage,
                                     byte[] bytes)
                              throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         message.replyWith( bytes )
         

        Parameters:
        requestMessage - the message to reply to
        bytes - the array of bytes to send
        Throws:
        JMSException
        Since:
        1.0
      • replyWith

        public static void replyWith​(Message requestMessage,
                                     byte[] bytes,
                                     Map<String,​Object> properties)
                              throws JMSException

        Send an array of bytes to the JMS broker.

        Example usage:

         def bytes = new byte[];
         ...
         message.replyWith( bytes, [ 'property': 'value' ] )
         

        Parameters:
        requestMessage - the message to reply to
        bytes - the array of bytes to send
        properties - Map of properties to set on the message. Property values must be a String or primitive. The producer options can also be configured with the following keys: persistentDelivery, timeToLive, priority, and ackMode.
        Throws:
        JMSException
      • sendAlert

        public static void sendAlert​(String message)
                              throws JMSException

        Send a message with the provided properties to the alert topic topic://io.toro.martini.alert.AlertQueue.

        Example usage:

         'Hello, world'.sendAlert()
         

        Parameters:
        message - alert message
        Throws:
        JMSException
        Since:
        1.0
      • sendAlert

        public static void sendAlert​(String message,
                                     int severity)
                              throws JMSException

        Send a message with the provided properties to the alert topic topic://io.toro.martini.alert.AlertQueue.

        Example usage:

         'Hello, world'.sendAlert( 1 )
         

        Parameters:
        message - alert message
        severity - severity of the alert
        Throws:
        JMSException
        Since:
        1.0
      • sendAlert

        public static void sendAlert​(String message,
                                     String source)
                              throws JMSException

        Send a message with the provided properties to the alert topic topic://io.toro.martini.alert.AlertQueue.

        Example usage:

         'Hello, world'.sendAlert( 'source' )
         

        Parameters:
        message - alert message
        source - the source of the alert
        Throws:
        JMSException
        Since:
        1.0
      • sendAlert

        public static void sendAlert​(String message,
                                     String source,
                                     int severity)
                              throws JMSException

        Send a message with the provided properties to the alert topic topic://io.toro.martini.alert.AlertQueue.

        Example usage:

         'Hello, world'.sendAlert( 'source', 0 )
         

        Parameters:
        message - alert message
        source - the source of the alert
        severity - severity of the alert
        Throws:
        JMSException
        Since:
        1.0
      • sendAlert

        public static void sendAlert​(String message,
                                     String source,
                                     int severity,
                                     Map<Serializable,​Serializable> properties)
                              throws JMSException

        Send a message with the provided properties to the alert topic topic://io.toro.martini.alert.AlertQueue.

        Example usage:

         'Hello, world'.sendAlert( 'source', 0, [ 'property': 'value' ] )
         

        Parameters:
        message - alert message
        source - the source of the alert
        severity - severity of the alert
        properties - properties of the alert
        Throws:
        JMSException
        Since:
        1.0
      • sendAlert

        public static void sendAlert​(AlertJMSMessage alertJMSMessage)
                              throws JMSException

        Send a message to the alert topic topic://io.toro.martini.alert.AlertQueue.

        Example usage:

         def message = new AlertJMSMessage( 'message', 'source', 0, [ 'property': 'value' ] )
         message.sendAlert()
         

        Parameters:
        alertJMSMessage - the message to be sent to JMS broker
        Throws:
        JMSException
        Since:
        1.0