org.apache.activemq.artemis.core.client.impl.ClientSessionImpl

Here are the examples of the java api class org.apache.activemq.artemis.core.client.impl.ClientSessionImpl taken from open source projects.

1. JmsProducerTest#multipleSendsUsingSetters()

View license
@Test
public void multipleSendsUsingSetters() throws Exception {
    jmsServer.createQueue(true, "q1", null, true, "/queues/q1");
    server.createQueue(SimpleString.toSimpleString("q1"), SimpleString.toSimpleString("q1"), null, true, false);
    Queue q1 = context.createQueue("q1");
    context.createProducer().setProperty("prop1", 1).setProperty("prop2", 2).send(q1, "Text1");
    context.createProducer().setProperty("prop1", 3).setProperty("prop2", 4).send(q1, "Text2");
    for (int i = 0; i < 100; i++) {
        context.createProducer().send(q1, "Text" + i);
    }
    ActiveMQSession sessionUsed = (ActiveMQSession) (((ActiveMQJMSContext) context).getUsedSession());
    ClientSessionImpl coreSession = (ClientSessionImpl) sessionUsed.getCoreSession();
    // JMSConsumer is supposed to cache the producer, each call to createProducer is supposed to always return the same producer
    assertEquals(1, coreSession.cloneProducers().size());
    JMSConsumer consumer = context.createConsumer(q1);
    TextMessage text = (TextMessage) consumer.receive(5000);
    assertNotNull(text);
    assertEquals("Text1", text.getText());
    assertEquals(1, text.getIntProperty("prop1"));
    assertEquals(2, text.getIntProperty("prop2"));
    text = (TextMessage) consumer.receive(5000);
    assertNotNull(text);
    assertEquals("Text2", text.getText());
    assertEquals(3, text.getIntProperty("prop1"));
    assertEquals(4, text.getIntProperty("prop2"));
    for (int i = 0; i < 100; i++) {
        assertEquals("Text" + i, consumer.receiveBody(String.class, 1000));
    }
    consumer.close();
    context.close();
}