Search in sources :

Example 81 with MessageProducer

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

the class ActivationContainerOverwriteSystemTest 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 82 with MessageProducer

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

the class ApiLog method get.

@GET
@Path("/{txt}")
public Response get(@PathParam("txt") String txt) throws JMSException {
    try (final Connection connection = connectionFactory.createConnection()) {
        connection.start();
        try (final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
            try (final MessageProducer producer = session.createProducer(vector)) {
                final Message msg = session.createMessage();
                msg.setStringProperty("txt", txt);
                producer.send(msg);
            }
        }
    }
    return Response.ok().build();
}
Also used : Message(javax.jms.Message) Connection(javax.jms.Connection) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 83 with MessageProducer

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

the class ContextLookupBmpBean method testJmsConnection.

private void testJmsConnection(final 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 84 with MessageProducer

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

the class EncBmpBean method testJmsConnection.

private void testJmsConnection(final 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 85 with MessageProducer

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

the class ContextLookupCmpBean method testJmsConnection.

private void testJmsConnection(final 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)

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