use of org.apache.activemq.command.DiscoveryEvent in project activemq-artemis by apache.
the class DiscoveryEventTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
DiscoveryEvent info = (DiscoveryEvent) object;
info.setServiceName("ServiceName:1");
info.setBrokerName("BrokerName:2");
}
use of org.apache.activemq.command.DiscoveryEvent in project fabric8 by jboss-fuse.
the class MQProfileTest method waitForBroker.
protected void waitForBroker(String groupName) throws Exception {
ServiceProxy<CuratorFramework> curatorProxy = ServiceProxy.createServiceProxy(bundleContext, CuratorFramework.class);
try {
CuratorFramework curator = curatorProxy.getService();
final CountDownLatch serviceLatch = new CountDownLatch(1);
final FabricDiscoveryAgent discoveryAgent = new FabricDiscoveryAgent();
discoveryAgent.setCurator(curator);
discoveryAgent.setGroupName(groupName);
discoveryAgent.setDiscoveryListener(new DiscoveryListener() {
@Override
public void onServiceAdd(DiscoveryEvent discoveryEvent) {
System.out.println("Service added:" + discoveryEvent.getServiceName());
serviceLatch.countDown();
try {
discoveryAgent.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onServiceRemove(DiscoveryEvent discoveryEvent) {
System.out.println("Service removed:" + discoveryEvent.getServiceName());
}
});
discoveryAgent.start();
Assert.assertTrue(serviceLatch.await(15, TimeUnit.MINUTES));
} finally {
curatorProxy.close();
}
}
Aggregations