use of org.apache.activemq.command.SessionInfo in project activemq-artemis by apache.
the class BrokerTest method testQueueSendThenAddConsumer.
public void testQueueSendThenAddConsumer() throws Exception {
// Start a producer
StubConnection connection = createConnection();
ConnectionInfo connectionInfo = createConnectionInfo();
SessionInfo sessionInfo = createSessionInfo(connectionInfo);
ProducerInfo producerInfo = createProducerInfo(sessionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
connection.send(producerInfo);
destination = createDestinationInfo(connection, connectionInfo, destinationType);
// Send a message to the broker.
connection.send(createMessage(producerInfo, destination, deliveryMode));
// Start the consumer
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.send(consumerInfo);
// Make sure the message was delivered.
Message m = receiveMessage(connection);
assertNotNull(m);
}
use of org.apache.activemq.command.SessionInfo in project activemq-artemis by apache.
the class BrokerTest method testConsumerPrefetchAtOne.
public void testConsumerPrefetchAtOne() throws Exception {
// Start a producer and consumer
StubConnection connection = createConnection();
ConnectionInfo connectionInfo = createConnectionInfo();
SessionInfo sessionInfo = createSessionInfo(connectionInfo);
ProducerInfo producerInfo = createProducerInfo(sessionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
connection.send(producerInfo);
destination = createDestinationInfo(connection, connectionInfo, destinationType);
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
consumerInfo.setPrefetchSize(1);
connection.send(consumerInfo);
// Send 2 messages to the broker.
connection.send(createMessage(producerInfo, destination, deliveryMode));
connection.send(createMessage(producerInfo, destination, deliveryMode));
// Make sure only 1 message was delivered.
Message m = receiveMessage(connection);
assertNotNull(m);
assertNoMessagesLeft(connection);
}
use of org.apache.activemq.command.SessionInfo in project activemq-artemis by apache.
the class DemandForwardingBridgeTest method testSendThenAddConsumer.
public void testSendThenAddConsumer() throws Exception {
// Start a producer on local broker
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo);
destination = createDestinationInfo(connection1, connectionInfo1, destinationType);
// Start a consumer on a remote broker
final StubConnection connection2 = createRemoteConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
// Send the message to the local broker.
connection1.send(createMessage(producerInfo, destination, deliveryMode));
// Verify that the message stayed on the local broker.
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
connection1.send(consumerInfo1);
Message m = receiveMessage(connection1);
assertNotNull(m);
// Close consumer to cause the message to rollback.
connection1.send(consumerInfo1.createRemoveCommand());
final DestinationStatistics destinationStatistics = broker.getDestination(destination).getDestinationStatistics();
assertEquals("broker dest stat dispatched", 1, destinationStatistics.getDispatched().getCount());
assertEquals("broker dest stat dequeues", 0, destinationStatistics.getDequeues().getCount());
assertEquals("broker dest stat forwards", 0, destinationStatistics.getForwards().getCount());
// Now create remote consumer that should cause message to move to this
// remote consumer.
final ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
connection2.request(consumerInfo2);
// Make sure the message was delivered via the remote.
assertTrue("message was received", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
Message msg = receiveMessage(connection2);
if (msg != null) {
connection2.request(createAck(consumerInfo2, msg, 1, MessageAck.STANDARD_ACK_TYPE));
return true;
}
return false;
}
}));
assertTrue("broker dest stat forwards", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 1 == destinationStatistics.getForwards().getCount();
}
}));
assertEquals("broker dest stat dequeues", 1, destinationStatistics.getDequeues().getCount());
}
use of org.apache.activemq.command.SessionInfo in project activemq-artemis by apache.
the class DemandForwardingBridgeTest method testAddConsumerThenSend.
public void testAddConsumerThenSend() throws Exception {
// Start a producer on local broker
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo);
destination = createDestinationInfo(connection1, connectionInfo1, destinationType);
// Start a consumer on a remote broker
StubConnection connection2 = createRemoteConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo2, destination);
connection2.send(consumerInfo);
// subscriptions.
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
// Send the message to the local boker.
connection1.request(createMessage(producerInfo, destination, deliveryMode));
// Make sure the message was delivered via the remote.
receiveMessage(connection2);
}
use of org.apache.activemq.command.SessionInfo in project activemq-artemis by apache.
the class DemandForwardingBridgeFilterTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
producerConnection = createConnection();
ConnectionInfo producerConnectionInfo = createConnectionInfo();
SessionInfo producerSessionInfo = createSessionInfo(producerConnectionInfo);
producerInfo = createProducerInfo(producerSessionInfo);
producerConnection.send(producerConnectionInfo);
producerConnection.send(producerSessionInfo);
producerConnection.send(producerInfo);
consumerConnection = createRemoteConnection();
ConnectionInfo consumerConnectionInfo = createConnectionInfo();
consumerSessionInfo = createSessionInfo(consumerConnectionInfo);
consumerConnection.send(consumerConnectionInfo);
consumerConnection.send(consumerSessionInfo);
}
Aggregations