Search in sources :

Example 56 with Message

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

the class MDBTestCase method testAnnoBasedMDB.

/**
     * Test an annotation based MDB with properties substitution
     * @throws Exception
     */
@Test
public void testAnnoBasedMDB() throws Exception {
    this.jmsUtil.sendTextMessage("Say Nihao to " + AnnoBasedMDB.class.getName(), this.annoQueue, this.annoReplyQueue);
    final Message reply = this.jmsUtil.receiveMessage(annoReplyQueue, 5000);
    Assert.assertNotNull("Reply message was null on reply queue: " + this.annoReplyQueue, reply);
}
Also used : Message(javax.jms.Message) Test(org.junit.Test)

Example 57 with Message

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

the class MDBProxyBean method trigger.

@Override
public void trigger() throws Exception {
    final String goodMorning = "Good morning";
    // send as ObjectMessage
    // this.jmsUtil = (JMSMessagingUtil) getInitialContext().lookup(getEJBJNDIBinding());
    this.jmsUtil.sendTextMessage(goodMorning, this.queue, this.replyQueue);
    // wait for an reply
    final Message reply = this.jmsUtil.receiveMessage(replyQueue, 5000);
    // test the reply
    final TextMessage textMessage = (TextMessage) reply;
    Assert.assertEquals("Unexpected reply message on reply queue: " + this.replyQueue, CdiIntegrationMDB.REPLY, textMessage.getText());
}
Also used : TextMessage(javax.jms.TextMessage) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage)

Example 58 with Message

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

the class MDB20MessageSelectorTestCase method retestMessageSelectors.

/**
     * Re-tests 2 messages, both of them with the selected format.
     */
@Test
public void retestMessageSelectors() {
    sendTextMessage("Say 1st hello to " + EJB2xMDB.class.getName() + " in 1.1 format", queue, replyQueueA, "Version 1.1");
    final Message replyA = receiveMessage(replyQueueA, TimeoutUtil.adjust(1000));
    Assert.assertNotNull("Missing reply from " + replyQueueA, replyA);
    sendTextMessage("Say 2nd hello to " + EJB2xMDB.class.getName() + " in 1.1 format", queue, replyQueueB, "Version 1.1");
    final Message replyB = receiveMessage(replyQueueB, TimeoutUtil.adjust(1000));
    Assert.assertNotNull("Missing reply from " + replyQueueB, replyB);
}
Also used : Message(javax.jms.Message) Test(org.junit.Test)

Example 59 with Message

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

the class MDB20MessageSelectorTestCase method testMessageSelectors.

/**
     * Tests 2 messages, only one of them with the selected format.
     */
@Test
public void testMessageSelectors() {
    sendTextMessage("Say 1st hello to " + EJB2xMDB.class.getName() + " in 1.0 format", queue, replyQueueA, "Version 1.0");
    final Message replyA = receiveMessage(replyQueueA, TimeoutUtil.adjust(1000));
    Assert.assertNull("Unexpected reply from " + replyQueueA, replyA);
    sendTextMessage("Say 2nd hello to " + EJB2xMDB.class.getName() + " in 1.1 format", queue, replyQueueB, "Version 1.1");
    final Message replyB = receiveMessage(replyQueueB, TimeoutUtil.adjust(1000));
    Assert.assertNotNull("Missing reply from " + replyQueueB, replyB);
}
Also used : Message(javax.jms.Message) Test(org.junit.Test)

Example 60 with Message

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

the class MDB20TopicTestCase method testEjb20TopicMDBs.

/**
     * Tests 2 MDBs both listening on a topic.
     */
@Test
public void testEjb20TopicMDBs() {
    sendTextMessage("Say hello to the topic", topic);
    final Message replyA = receiveMessage(replyQueueA, TimeoutUtil.adjust(5000));
    Assert.assertNotNull("Reply message was null on reply queue: " + replyQueueA, replyA);
    final Message replyB = receiveMessage(replyQueueB, TimeoutUtil.adjust(5000));
    Assert.assertNotNull("Reply message was null on reply queue: " + replyQueueB, replyB);
}
Also used : Message(javax.jms.Message) Test(org.junit.Test)

Aggregations

Message (javax.jms.Message)230 TextMessage (javax.jms.TextMessage)103 Test (org.junit.Test)91 Session (javax.jms.Session)86 JMSException (javax.jms.JMSException)77 MessageProducer (javax.jms.MessageProducer)64 ObjectMessage (javax.jms.ObjectMessage)52 MessageConsumer (javax.jms.MessageConsumer)50 Connection (javax.jms.Connection)45 BytesMessage (javax.jms.BytesMessage)37 Destination (javax.jms.Destination)30 MapMessage (javax.jms.MapMessage)26 Queue (javax.jms.Queue)20 ConnectionFactory (javax.jms.ConnectionFactory)18 QueueSession (javax.jms.QueueSession)17 MessageCreator (org.springframework.jms.core.MessageCreator)15 MessageListener (javax.jms.MessageListener)12 Map (java.util.Map)10 StreamMessage (javax.jms.StreamMessage)10 TemporaryQueue (javax.jms.TemporaryQueue)9