use of com.axway.ats.action.exceptions.JmsMessageException in project ats-framework by Axway.
the class JmsClient method doConnect.
private synchronized ManagedConnection doConnect() {
releaseConnection();
final ManagedConnection connection = createManagedConnection();
try {
connection.start();
} catch (JMSException e) {
connection.shutdown();
throw new JmsMessageException("Error starting JMS connection from connection factory '" + defaultConnectionFactoryName + "'", e);
}
this.connection = connection;
return connection;
}
use of com.axway.ats.action.exceptions.JmsMessageException in project ats-framework by Axway.
the class JmsClient method sendTextMessageToQueue.
/**
* Send a text message to a queue
*
* @param queueName queue name
* @param textMessage message content
* @param properties message properties or null if none
*/
@PublicAtsApi
public void sendTextMessageToQueue(final String queueName, final String textMessage, final Map<String, ?> properties) {
try {
final Session session = loadSession(false, Session.AUTO_ACKNOWLEDGE);
doSendTextMessage(session, session.createQueue(queueName), textMessage, properties);
} catch (Exception e) {
throw new JmsMessageException("Failed to send text message to queue " + queueName, e);
}
}
use of com.axway.ats.action.exceptions.JmsMessageException in project ats-framework by Axway.
the class JmsClient method cleanupMessagesQueue.
/**
* Read all messages from a queue
*
* @param queueName queue name
* @throws JMSException
*/
@PublicAtsApi
public void cleanupMessagesQueue(final String queueName) throws JMSException {
try {
final Session session = loadSession(false, Session.AUTO_ACKNOWLEDGE);
doCleanupQueue(session, session.createQueue(queueName));
log.info("Successfully cleanedup message queue " + queueName + ". This is done by reading all existing messages.");
} catch (Exception e) {
throw new JmsMessageException("Failed to cleanup message queue " + queueName, e);
}
}
use of com.axway.ats.action.exceptions.JmsMessageException in project ats-framework by Axway.
the class JmsClient method createManagedConnection.
private ManagedConnection createManagedConnection() {
final ManagedConnection connection;
final ConnectionFactory connectionFactory = getConnectionFactory();
try {
if (!StringUtils.isNullOrEmpty(this.username)) {
connection = ManagedConnection.create(connectionFactory.createConnection(this.username, this.password));
} else {
connection = ManagedConnection.create(connectionFactory.createConnection());
}
} catch (JMSException e) {
throw new JmsMessageException("Error creating JMS connection from connection factory '" + defaultConnectionFactoryName + "'", e);
}
return connection;
}
use of com.axway.ats.action.exceptions.JmsMessageException in project ats-framework by Axway.
the class JmsClient method sendTextMessageToTopic.
/**
* Send a text message to a topic
*
* @param topicName topic name
* @param textMessage message content
* @param properties message properties or null if none
*/
@PublicAtsApi
public void sendTextMessageToTopic(final String topicName, final String textMessage, final Map<String, ?> properties) {
try {
final Session session = loadSession(false, Session.AUTO_ACKNOWLEDGE);
doSendTextMessage(session, session.createTopic(topicName), textMessage, properties);
} catch (Exception e) {
throw new JmsMessageException("Failed to send text message to topic " + topicName, e);
}
}
Aggregations