Example usage for javax.jms QueueConnection createSession

List of usage examples for javax.jms QueueConnection createSession

Introduction

In this page you can find the example usage for javax.jms QueueConnection createSession.

Prototype


Session createSession(boolean transacted, int acknowledgeMode) throws JMSException;

Source Link

Document

Creates a Session object, specifying transacted and acknowledgeMode .

Usage

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  www .j a  v  a2 s  .  c o  m
 * @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);
            }
        }
    }
}