use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class ProxyConnectorTest method testSendAndConsume.
public void testSendAndConsume() throws Exception {
// Start a producer on local broker using the proxy
StubConnection connection1 = createProxyConnection();
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);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
connection1.send(consumerInfo1);
// Start a consumer on a remote broker using a proxy connection.
StubConnection connection2 = createRemoteProxyConnection();
ConnectionInfo connectionInfo2 = createConnectionInfo();
SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
connection2.send(connectionInfo2);
connection2.send(sessionInfo2);
ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
connection2.send(consumerInfo2);
// Either that or make consumer retroactive
try {
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
// Send the message to the local broker.
connection1.request(createMessage(producerInfo, destination, deliveryMode));
// Verify that the message Was sent to the remote broker and the local
// broker.
Message m;
m = receiveMessage(connection1);
assertNotNull(m);
assertNoMessagesLeft(connection1);
m = receiveMessage(connection2);
assertNotNull(m);
assertNoMessagesLeft(connection2);
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class ProxyTestSupport method tearDown.
@Override
protected void tearDown() throws Exception {
for (Iterator<StubConnection> iter = connections.iterator(); iter.hasNext(); ) {
StubConnection connection = iter.next();
connection.stop();
iter.remove();
}
remoteBroker.stop();
super.tearDown();
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class ProxyTestSupport 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;
}
use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.
the class ProxyTestSupport method createProxyConnection.
protected StubConnection createProxyConnection() throws Exception {
Transport transport = TransportFactory.connect(proxyConnector.getServer().getConnectURI());
StubConnection connection = new StubConnection(transport);
connections.add(connection);
return connection;
}
Aggregations