Package com.axway.ats.action.jms
Class JmsClient
- java.lang.Object
-
- com.axway.ats.action.jms.JmsClient
-
public class JmsClient extends Object
A JMS client class
-
-
Constructor Summary
Constructors Constructor Description JmsClient()
JmsClient(String brokerURI)
JmsClient(InitialContext context, String defaultConnectionFactoryName)
Basic constructorJmsClient(InitialContext context, String defaultConnectionFactoryName, String brokerURI)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanupMessagesQueue(String queueName)
Read all messages from a queuevoid
createTopic(String topicName)
Create a topicjavax.jms.Message[]
getCollectedTopicMessages(String topicName)
Get the current list of collected messages on this topic.javax.jms.Message
receiveMessage(String jndiName)
Receive a messagejavax.jms.Message
receiveMessage(String jndiName, long timeout)
Receive a messagejavax.jms.Message
receiveMessage(javax.jms.Destination destination)
Receive a messagejavax.jms.Message
receiveMessage(javax.jms.Destination destination, long timeout)
Receive a messagejavax.jms.Message
receiveMessageFromQueue(String queueName)
Receive a message from queue.javax.jms.Message
receiveMessageFromQueue(String queueName, long timeout)
Receive a message from queue for a period of timejavax.jms.Message
receiveMessageFromTopic(String topicName)
Receive a message from a topic.javax.jms.Message
receiveMessageFromTopic(String topicName, long timeout)
Receive a message from topic for a period of timevoid
sendBinaryMessageToQueue(String queueName, byte[] bytes, Map<String,?> properties)
Send a binary message to a queuevoid
sendTextMessage(String jndiName, String textMessage, Map<String,?> properties)
Send a text messagevoid
sendTextMessage(javax.jms.Destination destination, String textMessage, Map<String,?> properties)
Send a text messagevoid
sendTextMessageToQueue(String queueName, String textMessage, Map<String,?> properties)
Send a text message to a queuevoid
sendTextMessageToTopic(String topicName, String textMessage, Map<String,?> properties)
Send a text message to a topicvoid
setBasicAuthentication(String username, String password)
Use basic authenticationstatic void
setDefaultStaticConnectionFactoryName(String factoryName)
static void
setDefaultStaticInitialContext(InitialContext context)
void
setKeepAlive(boolean isKeepAlive)
This option must be used in cases where we must not close the session after executing some of the available public methods.void
shutdown()
Shutdown the JMS client.void
startListeningToTopic(String topicName)
Start listening for messages on topicvoid
stopListeningToTopic(String topicName)
Stop listening for messages on topic
-
-
-
Constructor Detail
-
JmsClient
public JmsClient(InitialContext context, String defaultConnectionFactoryName, String brokerURI) throws NamingException
- Throws:
NamingException
-
JmsClient
public JmsClient(String brokerURI) throws NamingException
- Throws:
NamingException
-
JmsClient
public JmsClient(InitialContext context, String defaultConnectionFactoryName) throws NamingException
Basic constructor- Parameters:
context
- the initial contextdefaultConnectionFactoryName
- default connection factory name- Throws:
NamingException
-
JmsClient
public JmsClient() throws NamingException
- Throws:
NamingException
-
-
Method Detail
-
setDefaultStaticInitialContext
public static void setDefaultStaticInitialContext(InitialContext context)
-
setDefaultStaticConnectionFactoryName
public static void setDefaultStaticConnectionFactoryName(String factoryName)
-
setBasicAuthentication
public void setBasicAuthentication(String username, String password)
Use basic authentication- Parameters:
username
- the user namepassword
- the user password
-
setKeepAlive
public void setKeepAlive(boolean isKeepAlive)
This option must be used in cases where we must not close the session after executing some of the available public methods. For example, if you subscribe to listen for topic messages and then send a message, the last step will close the session which kills the listening process. In such case the session must not be closed.- Parameters:
isKeepAlive
-
-
shutdown
public void shutdown()
Shutdown the JMS client. This closes all connections and sessions.
-
sendTextMessage
public void sendTextMessage(String jndiName, String textMessage, Map<String,?> properties)
Send a text message- Parameters:
jndiName
-textMessage
- message contentproperties
- message properties or null if none
-
sendTextMessage
public void sendTextMessage(javax.jms.Destination destination, String textMessage, Map<String,?> properties)
Send a text message- Parameters:
destination
- message destinationtextMessage
- message contentproperties
- message properties or null if none
-
sendTextMessageToQueue
public void sendTextMessageToQueue(String queueName, String textMessage, Map<String,?> properties)
Send a text message to a queue- Parameters:
queueName
- queue nametextMessage
- message contentproperties
- message properties or null if none
-
sendTextMessageToTopic
public void sendTextMessageToTopic(String topicName, String textMessage, Map<String,?> properties)
Send a text message to a topic- Parameters:
topicName
- topic nametextMessage
- message contentproperties
- message properties or null if none
-
sendBinaryMessageToQueue
public void sendBinaryMessageToQueue(String queueName, byte[] bytes, Map<String,?> properties)
Send a binary message to a queue- Parameters:
queueName
- queue namebytes
- message contentproperties
- message properties or null if none
-
receiveMessage
public javax.jms.Message receiveMessage(String jndiName)
Receive a message- Parameters:
jndiName
-- Returns:
- the received message
-
receiveMessage
public javax.jms.Message receiveMessage(String jndiName, long timeout)
Receive a message- Parameters:
jndiName
-timeout
- timeout period in milliseconds- Returns:
- the received message
-
receiveMessage
public javax.jms.Message receiveMessage(javax.jms.Destination destination)
Receive a message- Parameters:
destination
- remote destination- Returns:
- the received message
-
receiveMessage
public javax.jms.Message receiveMessage(javax.jms.Destination destination, long timeout)
Receive a message- Parameters:
destination
- remote destinationtimeout
- timeout period in milliseconds- Returns:
- the received message
-
receiveMessageFromQueue
public javax.jms.Message receiveMessageFromQueue(String queueName)
Receive a message from queue. Waits indefinitely.- Parameters:
queueName
- queue name- Returns:
- the received message
-
receiveMessageFromQueue
public javax.jms.Message receiveMessageFromQueue(String queueName, long timeout)
Receive a message from queue for a period of time- Parameters:
queueName
- queue nametimeout
- timeout period in milliseconds- Returns:
- the received message
-
receiveMessageFromTopic
public javax.jms.Message receiveMessageFromTopic(String topicName)
Receive a message from a topic. Waits indefinitely.- Parameters:
topicName
- topic name- Returns:
- the received message
-
receiveMessageFromTopic
public javax.jms.Message receiveMessageFromTopic(String topicName, long timeout)
Receive a message from topic for a period of time- Parameters:
topicName
- topic nametimeout
- timeout period in milliseconds- Returns:
- the received message
-
cleanupMessagesQueue
public void cleanupMessagesQueue(String queueName) throws javax.jms.JMSException
Read all messages from a queue- Parameters:
queueName
- queue name- Throws:
javax.jms.JMSException
-
createTopic
public void createTopic(String topicName)
Create a topic- Parameters:
topicName
- the topic name
-
startListeningToTopic
public void startListeningToTopic(String topicName)
Start listening for messages on topic- Parameters:
topicName
- the topic name
-
stopListeningToTopic
public void stopListeningToTopic(String topicName)
Stop listening for messages on topic- Parameters:
topicName
- the topic name
-
getCollectedTopicMessages
public javax.jms.Message[] getCollectedTopicMessages(String topicName)
Get the current list of collected messages on this topic.- Parameters:
topicName
- the topic name- Returns:
- the messages.
-
-