org.apache.jmeter.protocol.jms

## Class Utils

- java.lang.Object
- - org.apache.jmeter.protocol.jms.Utils

-     public final class Utils
      extends java.lang.Object

  Utility methods for JMS protocol. WARNING - the API for this class is likely to change!

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_NO_EXPIRY`
    `static java.lang.String` | `DEFAULT_PRIORITY_4`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Utils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addJMSProperties(javax.jms.Message msg, java.util.Map<java.lang.String,java.lang.Object> map)` Set JMS Properties to msg
    `static void` | `close(javax.jms.Connection closeable, org.slf4j.Logger log)`
    `static void` | `close(javax.jms.MessageConsumer closeable, org.slf4j.Logger log)`
    `static void` | `close(javax.jms.MessageProducer closeable, org.slf4j.Logger log)`
    `static void` | `close(javax.jms.Session closeable, org.slf4j.Logger log)`
    `static JMSProperties` | `convertArgumentsToJmsProperties(Arguments args)` Converts `Arguments` to `JMSProperties` defaulting to String type Used to convert version <= 2.10 test plans
    `static javax.jms.Connection` | `getConnection(javax.naming.Context ctx, java.lang.String factoryName)` Obtain the queue connection from the context and factory name.
    `static java.lang.String` | `getFromEnvironment(javax.naming.Context context, java.lang.String key)` Get value from Context environment taking into account non fully compliant JNDI implementations
    `static javax.jms.Destination` | `lookupDestination(javax.naming.Context context, java.lang.String name)` Method will lookup a given destination (topic/queue) using JNDI.
    `static java.lang.String` | `messageProperties(javax.jms.Message msg)`
    `static java.lang.StringBuilder` | `messageProperties(java.lang.StringBuilder sb, javax.jms.Message msg)`
    `static java.lang.StringBuilder` | `requestHeaders(java.lang.StringBuilder sb, javax.jms.Message msg)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_PRIORITY_4

          public static final java.lang.String DEFAULT_PRIORITY_4

      See Also:
        Constant Field Values

    - #### DEFAULT_NO_EXPIRY

          public static final java.lang.String DEFAULT_NO_EXPIRY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Utils

          public Utils()

  - ### Method Detail

    - #### close

          public static void close(javax.jms.MessageConsumer closeable,
                                   org.slf4j.Logger log)

    - #### close

          public static void close(javax.jms.Session closeable,
                                   org.slf4j.Logger log)

    - #### close

          public static void close(javax.jms.Connection closeable,
                                   org.slf4j.Logger log)

    - #### close

          public static void close(javax.jms.MessageProducer closeable,
                                   org.slf4j.Logger log)

      Parameters:
        `closeable` - `MessageProducer`
        `log` - `Logger`

    - #### messageProperties

          public static java.lang.String messageProperties(javax.jms.Message msg)

    - #### messageProperties

          public static java.lang.StringBuilder messageProperties(java.lang.StringBuilder sb,
                                                                  javax.jms.Message msg)

    - #### requestHeaders

          public static java.lang.StringBuilder requestHeaders(java.lang.StringBuilder sb,
                                                               javax.jms.Message msg)

    - #### lookupDestination

          public static javax.jms.Destination lookupDestination(javax.naming.Context context,
                                                                java.lang.String name)
                                                         throws javax.naming.NamingException

      Method will lookup a given destination (topic/queue) using JNDI.
      Parameters:
        `context` - context to use for lookup
        `name` - the destination name
      Returns:
        the destination, never null
      Throws:
        `javax.naming.NamingException` - if the name cannot be found as a Destination

    - #### getFromEnvironment

          public static java.lang.String getFromEnvironment(javax.naming.Context context,
                                                            java.lang.String key)
                                                     throws javax.naming.NamingException

      Get value from Context environment taking into account non fully compliant JNDI implementations
      Parameters:
        `context` - context to use
        `key` - key to lookup in contexts environment
      Returns:
        String or `null` if context.getEnvironment() is not compliant
      Throws:
        `javax.naming.NamingException` - if a naming problem occurs while getting the environment

    - #### getConnection

          public static javax.jms.Connection getConnection(javax.naming.Context ctx,
                                                           java.lang.String factoryName)
                                                    throws javax.jms.JMSException,
                                                           javax.naming.NamingException

      Obtain the queue connection from the context and factory name.
      Parameters:
        `ctx` - context to use
        `factoryName` - name of the object factory to look up in `context`
      Returns:
        the queue connection
      Throws:
        `javax.jms.JMSException` - when creation of the connection fails
        `javax.naming.NamingException` - when lookup in context fails

    - #### addJMSProperties

          public static void addJMSProperties(javax.jms.Message msg,
                                              java.util.Map<java.lang.String,java.lang.Object> map)
                                       throws javax.jms.JMSException

      Set JMS Properties to msg
      Parameters:
        `msg` - Message to operate on
        `map` - Map of Properties to be set on the message
      Throws:
        `javax.jms.JMSException` - when `msg` throws a `JMSException` while the properties get set

    - #### convertArgumentsToJmsProperties

          public static JMSProperties convertArgumentsToJmsProperties(Arguments args)

      Converts `Arguments` to `JMSProperties` defaulting to String type Used to convert version <= 2.10 test plans
      Parameters:
        `args` - `Arguments` to be converted
      Returns:
        jmsProperties The converted `JMSProperties`

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.