ClientConsumer cons1 = session1.createConsumer(queueName0);
session1.start();
Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
InVMConnector.failOnCreateConnection = true;
InVMConnector.numberOfFailures = reconnectAttempts - 1;
forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));
final int numMessages = 10;
SimpleString propKey = new SimpleString("propkey");
for (int i = 0; i < numMessages; i++)
{
ClientMessage message = session0.createMessage(false);
message.putIntProperty(propKey, i);
prod0.send(message);
}
for (int i = 0; i < numMessages; i++)
{
ClientMessage r1 = cons1.receive(1500);
Assert.assertNotNull(r1);
Assert.assertEquals(i, r1.getObjectProperty(propKey));
}
// Fail again - should reconnect
forwardingConnection = ((BridgeImpl)bridge).getForwardingConnection();
InVMConnector.failOnCreateConnection = true;
InVMConnector.numberOfFailures = reconnectAttempts - 1;
forwardingConnection.fail(new HornetQException(HornetQException.NOT_CONNECTED));
for (int i = 0; i < numMessages; i++)
{
ClientMessage message = session0.createMessage(false);
message.putIntProperty(propKey, i);