use of org.apache.activemq.command.ConsumerId in project activemq-artemis by apache.
the class ConsumerIdTest method createObject.
@Override
public Object createObject() throws Exception {
ConsumerId info = new ConsumerId();
populateObject(info);
return info;
}
use of org.apache.activemq.command.ConsumerId in project activemq-artemis by apache.
the class NetworkRouteTest method before.
@Before
public void before() throws Exception {
control = EasyMock.createControl();
localBroker = control.createMock(Transport.class);
remoteBroker = control.createMock(Transport.class);
NetworkBridgeConfiguration configuration = new NetworkBridgeConfiguration();
brokerService = new BrokerService();
BrokerInfo remoteBrokerInfo = new BrokerInfo();
configuration.setDuplex(true);
configuration.setNetworkTTL(5);
brokerService.setBrokerId("broker-1");
brokerService.setPersistent(false);
brokerService.setUseJmx(false);
brokerService.start();
brokerService.waitUntilStarted();
remoteBrokerInfo.setBrokerId(new BrokerId("remote-broker-id"));
remoteBrokerInfo.setBrokerName("remote-broker-name");
localBroker.setTransportListener(EasyMock.isA(TransportListener.class));
ArgHolder localListenerRef = ArgHolder.holdArgsForLastVoidCall();
remoteBroker.setTransportListener(EasyMock.isA(TransportListener.class));
ArgHolder remoteListenerRef = ArgHolder.holdArgsForLastVoidCall();
localBroker.start();
remoteBroker.start();
remoteBroker.oneway(EasyMock.isA(Object.class));
EasyMock.expectLastCall().times(4);
remoteBroker.oneway(EasyMock.isA(Object.class));
ExpectationWaiter remoteInitWaiter = ExpectationWaiter.waiterForLastVoidCall();
localBroker.oneway(remoteBrokerInfo);
EasyMock.expect(localBroker.request(EasyMock.isA(Object.class))).andReturn(null);
localBroker.oneway(EasyMock.isA(Object.class));
ExpectationWaiter localInitWaiter = ExpectationWaiter.waiterForLastVoidCall();
control.replay();
DurableConduitBridge bridge = new DurableConduitBridge(configuration, localBroker, remoteBroker);
bridge.setBrokerService(brokerService);
bridge.start();
localListener = (TransportListener) localListenerRef.getArguments()[0];
Assert.assertNotNull(localListener);
remoteListener = (TransportListener) remoteListenerRef.getArguments()[0];
Assert.assertNotNull(remoteListener);
remoteListener.onCommand(remoteBrokerInfo);
remoteInitWaiter.assertHappens(5, TimeUnit.SECONDS);
localInitWaiter.assertHappens(5, TimeUnit.SECONDS);
control.verify();
control.reset();
ActiveMQMessage msg = new ActiveMQMessage();
msg.setDestination(new ActiveMQTopic("test"));
msgDispatch = new MessageDispatch();
msgDispatch.setMessage(msg);
ConsumerInfo path1 = new ConsumerInfo();
path1.setDestination(msg.getDestination());
path1.setConsumerId(new ConsumerId(new SessionId(new ConnectionId("conn-id-1"), 1), 3));
path1.setBrokerPath(new BrokerId[] { new BrokerId("remote-broker-id"), new BrokerId("server(1)-broker-id") });
path1Msg = new ActiveMQMessage();
path1Msg.setDestination(AdvisorySupport.getConsumerAdvisoryTopic(path1.getDestination()));
path1Msg.setDataStructure(path1);
ConsumerInfo path2 = new ConsumerInfo();
path2.setDestination(path1.getDestination());
path2.setConsumerId(new ConsumerId(new SessionId(new ConnectionId("conn-id-2"), 2), 4));
path2.setBrokerPath(new BrokerId[] { new BrokerId("remote-broker-id"), new BrokerId("server(2)-broker-id"), new BrokerId("server(1)-broker-id") });
path2Msg = new ActiveMQMessage();
path2Msg.setDestination(path1Msg.getDestination());
path2Msg.setDataStructure(path2);
RemoveInfo removePath1 = new RemoveInfo(path1.getConsumerId());
RemoveInfo removePath2 = new RemoveInfo(path2.getConsumerId());
removePath1Msg = new ActiveMQMessage();
removePath1Msg.setDestination(path1Msg.getDestination());
removePath1Msg.setDataStructure(removePath1);
removePath2Msg = new ActiveMQMessage();
removePath2Msg.setDestination(path1Msg.getDestination());
removePath2Msg.setDataStructure(removePath2);
}
use of org.apache.activemq.command.ConsumerId in project activemq-artemis by apache.
the class ConcurrentConnectSimulationTest method testConcurrentConnection.
/*
* simulate failover and retry of connection before broker has killed connection
* which appears as a concurrent connect request to the broker
* see: https://issues.apache.org/activemq/browse/AMQ-2241
*/
public void testConcurrentConnection() throws Exception {
StubConnection connection1 = createConnection();
StubConnection connection2 = createConnection();
// reuse same connection info
ConnectionInfo connectionInfo = createConnectionInfo();
connection1.request(connectionInfo);
connection2.request(connectionInfo);
// second one should win out, verify using consumer on default session (watchAdvisories)
ConsumerId consumerId = new ConsumerId(new SessionId(connectionInfo.getConnectionId(), -1), 1);
ConsumerInfo consumerInfo = new ConsumerInfo(consumerId);
consumerInfo.setDestination(AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC);
connection2.request(consumerInfo);
}
use of org.apache.activemq.command.ConsumerId in project activemq-artemis by apache.
the class ConsumerIdTest method createObject.
@Override
public Object createObject() throws Exception {
ConsumerId info = new ConsumerId();
populateObject(info);
return info;
}
use of org.apache.activemq.command.ConsumerId in project activemq-artemis by apache.
the class ConsumerIdTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ConsumerId info = (ConsumerId) object;
info.setConnectionId("ConnectionId:1");
info.setSessionId(1);
info.setValue(2);
}
Aggregations