Search in sources :

Example 11 with JMSConsumer

use of javax.jms.JMSConsumer in project wildfly by wildfly.

the class AbstractMessagingHATestCase method receiveMessage.

protected static void receiveMessage(Context ctx, String destinationLookup, String expectedText) throws NamingException {
    ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
    assertNotNull(cf);
    Destination destination = (Destination) ctx.lookup(destinationLookup);
    assertNotNull(destination);
    try (JMSContext context = cf.createContext("guest", "guest")) {
        JMSConsumer consumer = context.createConsumer(destination);
        String text = consumer.receiveBody(String.class, 5000);
        assertNotNull(text);
        assertEquals(expectedText, text);
    }
}
Also used : Destination(javax.jms.Destination) ConnectionFactory(javax.jms.ConnectionFactory) JMSConsumer(javax.jms.JMSConsumer) JMSContext(javax.jms.JMSContext)

Example 12 with JMSConsumer

use of javax.jms.JMSConsumer in project wildfly by wildfly.

the class ClusteredMessagingTestCase method receiveMessage.

protected static void receiveMessage(Context ctx, String destinationLookup, String expectedText) throws NamingException {
    ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
    assertNotNull(cf);
    Destination destination = (Destination) ctx.lookup(destinationLookup);
    assertNotNull(destination);
    try (JMSContext context = cf.createContext("guest", "guest")) {
        JMSConsumer consumer = context.createConsumer(destination);
        receiveMessage(consumer, expectedText);
    }
}
Also used : Destination(javax.jms.Destination) ConnectionFactory(javax.jms.ConnectionFactory) JMSConsumer(javax.jms.JMSConsumer) JMSContext(javax.jms.JMSContext)

Example 13 with JMSConsumer

use of javax.jms.JMSConsumer in project wildfly by wildfly.

the class MDBWithVaultedPropertiesTestCase method sendAndReceiveMessage.

@Test
public void sendAndReceiveMessage() {
    try (JMSContext context = factory.createContext()) {
        TemporaryQueue replyTo = context.createTemporaryQueue();
        String text = UUID.randomUUID().toString();
        context.createProducer().setJMSReplyTo(replyTo).send(queue, text);
        JMSConsumer consumer = context.createConsumer(replyTo);
        String reply = consumer.receiveBody(String.class, 5000);
        assertEquals(text, reply);
    }
}
Also used : JMSConsumer(javax.jms.JMSConsumer) TemporaryQueue(javax.jms.TemporaryQueue) JMSContext(javax.jms.JMSContext) Test(org.junit.Test)

Example 14 with JMSConsumer

use of javax.jms.JMSConsumer in project wildfly by wildfly.

the class VaultedInjectedJMSContextTestCase method sendMessage.

@Test
public void sendMessage() throws JMSException {
    String text = UUID.randomUUID().toString();
    try (JMSContext context = factory.createContext()) {
        TemporaryQueue tempQueue = context.createTemporaryQueue();
        producerBean.sendToDestination(tempQueue, text);
        JMSConsumer consumer = context.createConsumer(tempQueue);
        String reply = consumer.receiveBody(String.class, adjust(2000));
        assertEquals(text, reply);
    }
}
Also used : JMSConsumer(javax.jms.JMSConsumer) TemporaryQueue(javax.jms.TemporaryQueue) JMSContext(javax.jms.JMSContext) Test(org.junit.Test)

Example 15 with JMSConsumer

use of javax.jms.JMSConsumer in project wildfly by wildfly.

the class MessagingBean method checkInjectedResources.

public void checkInjectedResources() {
    assertNotNull(queue1);
    assertNotNull(queue2);
    assertNotNull(queue3);
    assertNotNull(queue4);
    assertNotNull(topic1);
    assertNotNull(topic2);
    assertNotNull(factory1);
    assertNotNull(factory2);
    assertNotNull(factory3);
    assertNotNull(factory4);
    assertNotNull(factory5);
    assertNotNull(factory6);
    JMSContext context = factory3.createContext("guest", "guest", AUTO_ACKNOWLEDGE);
    JMSConsumer consumer = context.createConsumer(queue4);
    assertNotNull(consumer);
    consumer.close();
}
Also used : JMSConsumer(javax.jms.JMSConsumer) JMSContext(javax.jms.JMSContext)

Aggregations

JMSConsumer (javax.jms.JMSConsumer)17 JMSContext (javax.jms.JMSContext)15 Test (org.junit.Test)8 Destination (javax.jms.Destination)5 Message (javax.jms.Message)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 ConnectionFactory (javax.jms.ConnectionFactory)4 JMSRuntimeException (javax.jms.JMSRuntimeException)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 TemporaryQueue (javax.jms.TemporaryQueue)3 TextMessage (javax.jms.TextMessage)3 MessageListener (javax.jms.MessageListener)2 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 RequestScoped (javax.enterprise.context.RequestScoped)1 JMSException (javax.jms.JMSException)1 JMSProducer (javax.jms.JMSProducer)1 InitialContext (javax.naming.InitialContext)1 ContextsService (org.apache.webbeans.spi.ContextsService)1 After (org.junit.After)1