Search in sources :

Example 6 with JmsConnection

use of org.apache.qpid.jms.JmsConnection in project activemq-artemis by apache.

the class JMSWebSocketConnectionTest method testSendLargeMessageToClientFromAMQP.

@Ignore("Broker can't accept messages over 65535 right now")
@Test(timeout = 30000)
public void testSendLargeMessageToClientFromAMQP() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
    JmsConnection connection = (JmsConnection) factory.createConnection();
    sendLargeMessageViaAMQP();
    try {
        Session session = connection.createSession();
        Queue queue = session.createQueue(getQueueName());
        connection.start();
        MessageConsumer consumer = session.createConsumer(queue);
        Message message = consumer.receive(1000);
        assertNotNull(message);
        assertTrue(message instanceof BytesMessage);
    } finally {
        connection.close();
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) BytesMessage(javax.jms.BytesMessage) Message(javax.jms.Message) JmsConnectionFactory(org.apache.qpid.jms.JmsConnectionFactory) BytesMessage(javax.jms.BytesMessage) JmsConnection(org.apache.qpid.jms.JmsConnection) Queue(javax.jms.Queue) Session(javax.jms.Session) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with JmsConnection

use of org.apache.qpid.jms.JmsConnection in project activemq-artemis by apache.

the class JMSWebSocketConnectionTest method testSendReceiveOverWS.

@Test(timeout = 30000)
public void testSendReceiveOverWS() throws Exception {
    JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
    JmsConnection connection = (JmsConnection) factory.createConnection();
    try {
        Session session = connection.createSession();
        Queue queue = session.createQueue(getQueueName());
        MessageProducer producer = session.createProducer(queue);
        producer.send(session.createMessage());
        producer.close();
        connection.start();
        MessageConsumer consumer = session.createConsumer(queue);
        Message message = consumer.receive(1000);
        assertNotNull(message);
    } finally {
        connection.close();
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) BytesMessage(javax.jms.BytesMessage) Message(javax.jms.Message) JmsConnectionFactory(org.apache.qpid.jms.JmsConnectionFactory) JmsConnection(org.apache.qpid.jms.JmsConnection) MessageProducer(javax.jms.MessageProducer) Queue(javax.jms.Queue) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

JmsConnection (org.apache.qpid.jms.JmsConnection)7 Session (javax.jms.Session)6 Test (org.junit.Test)6 Message (javax.jms.Message)5 MessageConsumer (javax.jms.MessageConsumer)5 BytesMessage (javax.jms.BytesMessage)4 JmsConnectionFactory (org.apache.qpid.jms.JmsConnectionFactory)4 MessageProducer (javax.jms.MessageProducer)3 Queue (javax.jms.Queue)3 TextMessage (javax.jms.TextMessage)3 JmsDefaultPrefetchPolicy (org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Destination (javax.jms.Destination)1 JMSException (javax.jms.JMSException)1 MessageListener (javax.jms.MessageListener)1 QueueBrowser (javax.jms.QueueBrowser)1 Queue (org.apache.activemq.artemis.core.server.Queue)1 Ignore (org.junit.Ignore)1