Package org.logicblaze.lingo.jms

Source Code of org.logicblaze.lingo.jms.JmsSingleThreadedTest

package org.logicblaze.lingo.jms;

import org.logicblaze.lingo.jms.impl.SingleThreadedRequestor;

import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.TextMessage;

/**
* @author yuri
* @version $Revision: 1.2 $
*/
public class JmsSingleThreadedTest extends JmsTestSupport {
    public JmsSingleThreadedTest() {
    }

    public void testTimeout() throws Exception {
        SingleThreadedRequestor requestor = (SingleThreadedRequestor) createRequestor(getDestinationName());

        Session session = createSession();
        MessageConsumer receiver = session.createConsumer(session.createQueue(getDestinationName()));

        // clear old messages
        while (receiver.receive(1) != null) {
            ;
        }

        requestor.oneWay(null, session.createTextMessage("bonson"), 1);
        Thread.sleep(50);
        assertNull(receiver.receive(1));

        requestor.oneWay(null, session.createTextMessage("bonson2"), -1);
        TextMessage message = (TextMessage) receiver.receive(1000);
        assertNotNull(message);
        assertEquals("bonson2", message.getText());
    }

    public void testTimeouUsingPermanentQueue() throws Exception {
        SingleThreadedRequestor requestor = (SingleThreadedRequestor) createRequestor(getDestinationName(), getDestinationName() + ".ClientInbound");

        Session session = createSession();
        MessageConsumer receiver = session.createConsumer(session.createQueue(getDestinationName()));

        // clear old messages
        while (receiver.receive(1) != null) {
            ;
        }

        requestor.oneWay(null, session.createTextMessage("bonson"), 1);
        Thread.sleep(50);
        assertNull(receiver.receive(1));

        requestor.oneWay(null, session.createTextMessage("bonson2"), -1);
        TextMessage message = (TextMessage) receiver.receive(1000);
        assertNotNull(message);
        assertEquals("bonson2", message.getText());
    }
}
TOP

Related Classes of org.logicblaze.lingo.jms.JmsSingleThreadedTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.