Search in sources :

Example 76 with MessageProducer

use of javax.jms.MessageProducer in project tomee by apache.

the class LocalClientTest method testJmsConnection.

private void testJmsConnection(final javax.jms.Connection connection) throws JMSException {
    final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    final Topic topic = session.createTopic("test");
    final MessageProducer producer = session.createProducer(topic);
    producer.send(session.createMessage());
    producer.close();
    session.close();
    connection.close();
}
Also used : MessageProducer(javax.jms.MessageProducer) Topic(javax.jms.Topic) Session(javax.jms.Session)

Example 77 with MessageProducer

use of javax.jms.MessageProducer in project tomee by apache.

the class AMQXASupportTest method testConnection.

private void testConnection(final Connection connection) throws JMSException, InterruptedException {
    try {
        final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        final MessageProducer producer = session.createProducer(destination);
        producer.send(session.createTextMessage(TEXT));
        assertTrue(Listener.sync());
    } finally {
        try {
            connection.close();
        } catch (final JMSException e) {
        // no-op
        }
    }
}
Also used : JMSException(javax.jms.JMSException) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session)

Example 78 with MessageProducer

use of javax.jms.MessageProducer in project tomee by apache.

the class ActivationContainerOverwriteReadTheContainerConfigurationTest method testConnection.

private void testConnection(final Connection connection) throws JMSException, InterruptedException {
    try {
        final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        final MessageProducer producer = session.createProducer(destination);
        producer.send(session.createTextMessage(TEXT));
        assertTrue(Listener.sync());
    } finally {
        try {
            connection.close();
        } catch (final JMSException e) {
        // no-op
        }
    }
}
Also used : JMSException(javax.jms.JMSException) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session)

Example 79 with MessageProducer

use of javax.jms.MessageProducer in project tomee by apache.

the class JmsMdbContainerTest method sendMessage.

private void sendMessage(final ConnectionFactory connectionFactory, final String bean, final String text) throws JMSException, InterruptedException {
    WidgetBean.lock.lock();
    try {
        final Connection connection = connectionFactory.createConnection();
        connection.start();
        // Create a Session
        final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        final Queue queue = session.createQueue(bean);
        // Create a MessageProducer from the Session to the Topic or Queue
        final MessageProducer producer = session.createProducer(queue);
        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
        // Create a message
        final TextMessage message = session.createTextMessage(text);
        // Tell the producer to send the message
        producer.send(message);
        WidgetBean.messageRecieved.await();
    } finally {
        WidgetBean.lock.unlock();
    }
}
Also used : Connection(javax.jms.Connection) MessageProducer(javax.jms.MessageProducer) Queue(javax.jms.Queue) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session)

Example 80 with MessageProducer

use of javax.jms.MessageProducer in project tomee by apache.

the class ActivationContainerOverwriteSystemContainerIdTest method testConnection.

private void testConnection(final Connection connection) throws JMSException, InterruptedException {
    try {
        final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        final MessageProducer producer = session.createProducer(destination);
        producer.send(session.createTextMessage(TEXT));
        assertTrue(Listener.sync());
    } finally {
        try {
            connection.close();
        } catch (final JMSException e) {
        // no-op
        }
    }
}
Also used : JMSException(javax.jms.JMSException) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session)

Aggregations

MessageProducer (javax.jms.MessageProducer)184 Session (javax.jms.Session)131 TextMessage (javax.jms.TextMessage)74 Message (javax.jms.Message)64 Connection (javax.jms.Connection)60 Test (org.junit.Test)54 MessageConsumer (javax.jms.MessageConsumer)49 JMSException (javax.jms.JMSException)46 Topic (javax.jms.Topic)34 Destination (javax.jms.Destination)31 Queue (javax.jms.Queue)21 ConnectionFactory (javax.jms.ConnectionFactory)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 ObjectMessage (javax.jms.ObjectMessage)10 ModelNode (org.jboss.dmr.ModelNode)10 BytesMessage (javax.jms.BytesMessage)9 QueueSession (javax.jms.QueueSession)9 TemporaryQueue (javax.jms.TemporaryQueue)9 QueueConnection (javax.jms.QueueConnection)7 InitialContext (javax.naming.InitialContext)7