Example usage for javax.jms Session createTextMessage

List of usage examples for javax.jms Session createTextMessage

Introduction

In this page you can find the example usage for javax.jms Session createTextMessage.

Prototype


TextMessage createTextMessage() throws JMSException;

Source Link

Document

Creates a TextMessage object.

Usage

From source file:org.wso2.carbon.sample.jmsclient.JMSClientUtil.java

/**
 * Each message will be divided into groups and create the map message
 *
 * @param producer     Used for sending messages to a destination
 * @param session      Used to produce the messages to be sent
 * @param messagesList List of messages to be sent
 *//*from   w ww.  j  a  v  a  2  s. co  m*/
public static void publishTextMessage(MessageProducer producer, Session session, List<String> messagesList)
        throws JMSException {
    for (String message : messagesList) {
        TextMessage jmsMessage = session.createTextMessage();
        jmsMessage.setText(message);
        producer.send(jmsMessage);
    }
}

From source file:pl.psnc.synat.wrdz.zu.certificate.CertificateChecker.java

/**
 * Notifies the system monitor that the given user has a certificate that's beyond the expiration threshold.
 * //from   w  w  w  .j av a 2s. com
 * @param username
 *            name of the user with the (nearly) expired certificate
 */
private void notifyExpirationCheckFail(String username) {
    QueueConnection connection = null;
    try {
        connection = queueConnectionFactory.createQueueConnection();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        TextMessage message = session.createTextMessage();
        message.setText(username);
        session.createProducer(certificateQueue).send(message);
    } catch (JMSException e) {
        logger.error("Sending message to the JMS queue failed", e);
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (JMSException e) {
                logger.error("Error while closing a connection.", e);
            }
        }
    }
}