# Class Utils

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

public final class Utils extends Object
Utility methods for JMS protocol. WARNING - the API for this class is likely to change!

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_NO_EXPIRY`
`static final String`
`DEFAULT_PRIORITY_4`

## Constructor Summary

Constructors
Constructor
Description
`Utils()`

## Method Summary

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

### Methods inherited from class Object

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

## Field Details

### DEFAULT_PRIORITY_4

public static final String DEFAULT_PRIORITY_4

See Also:
  - Constant Field Values

### DEFAULT_NO_EXPIRY

public static final String DEFAULT_NO_EXPIRY

See Also:
  - Constant Field Values

## Constructor Details

### Utils

public Utils()

## Method Details

### close

public static void close(MessageConsumer closeable, Logger log)

### close

public static void close(Session closeable, Logger log)

### close

public static void close(Connection closeable, Logger log)

### close

public static void close(MessageProducer closeable, Logger log)

### messageProperties

public static String messageProperties(Message msg)

### messageProperties

public static StringBuilder messageProperties(StringBuilder sb, Message msg)

### requestHeaders

public static StringBuilder requestHeaders(StringBuilder sb, Message msg)

### lookupDestination

public static Destination lookupDestination(Context context, String name) throws 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:
  `NamingException` - if the name cannot be found as a Destination

### getFromEnvironment

public static final String getFromEnvironment(Context context, String key) throws 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:
  `NamingException` - if a naming problem occurs while getting the environment

### getConnection

public static Connection getConnection(Context ctx, String factoryName) throws JMSException, 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

### addJMSProperties

public static void addJMSProperties(Message msg, Map<String,Object> map) throws JMSException
Set JMS Properties to msg

Parameters:
  `msg` - Message to operate on
  `map` - Map of Properties to be set on the message

### convertArgumentsToJmsProperties

public static final 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`