IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Testing JMS Topic/Queue

    Posted Wed August 22, 2018 06:54 AM

    Hi Everyone,

    I’m am very new to JMS and I was wondering if there is a way we can do an automated testing for Topic/Queue. Just a test where a message is published successfully to the Topic/Queue.

    Thanks in advance
    Jay


    #Universal-Messaging-Broker
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Testing JMS Topic/Queue

    Posted Wed August 22, 2018 07:42 AM

    Below is some sample of test code where we can send some messages to topic and check the count of them on listener:

    
    Connection con = null;
    Session session = null;
    ConnectionFactory connectionFactory = new ConnectionFactoryImpl("nsp://localhost:9000");
    con = connectionFactory.createConnection();
    con.start();
    session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Topic topic = session.createTopic(topicName);
    
    new TestMessageListener(rname, topic.getTopicName(), true)
    
    MessageProducer producer = session.createProducer(topic);
    for (int j = 0; j < MESSAGE_COUNT; j++) {
    TextMessage message = session.createTextMessage();
    message.setText("publishToTopic:" + j);
    producer.send(topic, message);
    }
    
    assertEquals("listener should receive all messages", MESSAGE_COUNT, listener.getCount());

    HTH,
    Chandra


    #Universal-Messaging-Broker
    #webMethods
    #Integration-Server-and-ESB