Search in sources :

Example 6 with JmsMessageException

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;
}
Also used : JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) ManagedConnection(com.axway.ats.action.jms.model.connections.ManagedConnection) JMSException(javax.jms.JMSException)

Example 7 with JmsMessageException

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);
    }
}
Also used : JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) NamingException(javax.naming.NamingException) JMSException(javax.jms.JMSException) JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) Session(javax.jms.Session) ManagedSession(com.axway.ats.action.jms.model.sessions.ManagedSession) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 8 with JmsMessageException

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);
    }
}
Also used : JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) NamingException(javax.naming.NamingException) JMSException(javax.jms.JMSException) JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) Session(javax.jms.Session) ManagedSession(com.axway.ats.action.jms.model.sessions.ManagedSession) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 9 with JmsMessageException

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;
}
Also used : JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) ConnectionFactory(javax.jms.ConnectionFactory) ManagedConnection(com.axway.ats.action.jms.model.connections.ManagedConnection) JMSException(javax.jms.JMSException)

Example 10 with JmsMessageException

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);
    }
}
Also used : JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) NamingException(javax.naming.NamingException) JMSException(javax.jms.JMSException) JmsMessageException(com.axway.ats.action.exceptions.JmsMessageException) Session(javax.jms.Session) ManagedSession(com.axway.ats.action.jms.model.sessions.ManagedSession) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

JmsMessageException (com.axway.ats.action.exceptions.JmsMessageException)10 JMSException (javax.jms.JMSException)10 ManagedSession (com.axway.ats.action.jms.model.sessions.ManagedSession)7 Session (javax.jms.Session)7 PublicAtsApi (com.axway.ats.common.PublicAtsApi)6 NamingException (javax.naming.NamingException)5 ManagedConnection (com.axway.ats.action.jms.model.connections.ManagedConnection)2 BytesMessage (javax.jms.BytesMessage)2 Topic (javax.jms.Topic)2 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ConnectionFactory (javax.jms.ConnectionFactory)1 Message (javax.jms.Message)1 MessageListener (javax.jms.MessageListener)1 StreamMessage (javax.jms.StreamMessage)1 TextMessage (javax.jms.TextMessage)1