use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class AdvisoryBrokerTest method testProducerAdvisories.
public void testProducerAdvisories() throws Exception {
ActiveMQDestination queue = new ActiveMQQueue("test");
ActiveMQDestination destination = AdvisorySupport.getProducerAdvisoryTopic(queue);
// Setup a first connection
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
consumerInfo1.setPrefetchSize(100);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(consumerInfo1);
assertNoMessagesLeft(connection1);
// Setup a producer.
StubConnection connection2 = createConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
ProducerInfo producerInfo2 = createProducerInfo(sessionInfo2);
producerInfo2.setDestination(queue);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
connection2.send(producerInfo2);
// We should get an advisory of the new producer.
Message m1 = receiveMessage(connection1);
assertNotNull(m1);
assertNotNull(m1.getDataStructure());
assertEquals(((ProducerInfo) m1.getDataStructure()).getProducerId(), producerInfo2.getProducerId());
// Close the second connection.
connection2.request(closeConnectionInfo(connectionInfo2));
connection2.stop();
// We should get an advisory of the producer closing
m1 = receiveMessage(connection1);
assertNotNull(m1);
assertNotNull(m1.getDataStructure());
RemoveInfo r = (RemoveInfo) m1.getDataStructure();
assertEquals(r.getObjectId(), producerInfo2.getProducerId());
assertNoMessagesLeft(connection2);
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class RecoverExpiredMessagesTest method consumeExpected.
private void consumeExpected() throws Exception {
// Setup the consumer and receive the message.
StubConnection connection = createConnection();
ConnectionInfo connectionInfo = createConnectionInfo();
SessionInfo sessionInfo = createSessionInfo(connectionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.send(consumerInfo);
Message m = receiveMessage(connection);
assertNotNull("Should have received message " + expected.get(0) + " by now!", m);
assertEquals(expected.get(0), m.getMessageId().toString());
MessageAck ack = createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE);
connection.send(ack);
assertNoMessagesLeft(connection);
connection.request(closeConnectionInfo(connectionInfo));
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class NetworkTestSupport method createRemoteConnection.
protected StubConnection createRemoteConnection() throws Exception {
Transport transport = TransportFactory.connect(remoteConnector.getServer().getConnectURI());
StubConnection connection = new StubConnection(transport);
connections.add(connection);
return connection;
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class NetworkTestSupport method tearDown.
@Override
protected void tearDown() throws Exception {
for (Iterator<StubConnection> iter = connections.iterator(); iter.hasNext(); ) {
StubConnection connection = iter.next();
connection.stop();
iter.remove();
}
BrokerRegistry.getInstance().unbind("remotehost");
remoteConnector.stop();
connector.stop();
remoteBroker.stop();
remoteBroker.waitUntilStopped();
remotePersistenceAdapter.stop();
super.tearDown();
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class NetworkTestSupport method createConnection.
@Override
protected StubConnection createConnection() throws Exception {
Transport transport = TransportFactory.connect(connector.getServer().getConnectURI());
StubConnection connection = new StubConnection(transport);
connections.add(connection);
return connection;
}
Aggregations