use of org.apache.activemq.artemis.core.server.group.GroupingHandler in project activemq-artemis by apache.
the class PostOfficeImpl method createBindings.
@Override
public Bindings createBindings(final SimpleString address) throws Exception {
GroupingHandler groupingHandler = server.getGroupingHandler();
BindingsImpl bindings = new BindingsImpl(address, groupingHandler, pagingManager.getPageStore(address));
if (groupingHandler != null) {
groupingHandler.addListener(bindings);
}
return bindings;
}
use of org.apache.activemq.artemis.core.server.group.GroupingHandler in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method sendQueueInfoToQueue.
@Override
public void sendQueueInfoToQueue(final String queueName, final String address) throws Exception {
checkStarted();
clearIO();
try {
postOffice.sendQueueInfoToQueue(new SimpleString(queueName), new SimpleString(address == null ? "" : address));
GroupingHandler handler = server.getGroupingHandler();
if (handler != null) {
// the group handler would miss responses if the group was requested before the reset was done
// on that case we ask the groupinghandler to replay its send in case it's waiting for the information
handler.resendPending();
}
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.server.group.GroupingHandler in project activemq-artemis by apache.
the class ClusteredGroupingTest method testTimeoutOnSending.
@Test
public void testTimeoutOnSending() throws Exception {
setupServer(0, isFileStorage(), isNetty());
setupServer(1, isFileStorage(), isNetty());
setupServer(2, isFileStorage(), isNetty());
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1, 2);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0, 2);
setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 0, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1, 0);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2, 0);
final CountDownLatch latch = new CountDownLatch(BindingsImpl.MAX_GROUP_RETRY);
setUpGroupHandler(new GroupingHandler() {
@Override
public void awaitBindings() throws Exception {
}
@Override
public void addListener(UnproposalListener listener) {
}
@Override
public void resendPending() throws Exception {
}
@Override
public void remove(SimpleString groupid, SimpleString clusterName) throws Exception {
}
@Override
public void forceRemove(SimpleString groupid, SimpleString clusterName) throws Exception {
}
@Override
public SimpleString getName() {
return null;
}
@Override
public void remove(SimpleString id, SimpleString groupId, int distance) {
// To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void start() throws Exception {
// To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void stop() throws Exception {
// To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean isStarted() {
return false;
}
@Override
public Response propose(final Proposal proposal) throws Exception {
return null;
}
@Override
public void proposed(final Response response) throws Exception {
System.out.println("ClusteredGroupingTest.proposed");
}
@Override
public void sendProposalResponse(final Response response, final int distance) throws Exception {
System.out.println("ClusteredGroupingTest.send");
}
@Override
public Response receive(final Proposal proposal, final int distance) throws Exception {
latch.countDown();
return null;
}
@Override
public void onNotification(final Notification notification) {
System.out.println("ClusteredGroupingTest.onNotification " + notification);
}
@Override
public void addGroupBinding(final GroupBinding groupBinding) {
System.out.println("ClusteredGroupingTest.addGroupBinding");
}
@Override
public Response getProposal(final SimpleString fullID, boolean touchTime) {
return null;
}
}, 0);
startServers(0, 1, 2);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
createQueue(0, "queues.testaddress", "queue0", null, false);
createQueue(1, "queues.testaddress", "queue0", null, false);
createQueue(2, "queues.testaddress", "queue0", null, false);
addConsumer(0, 0, "queue0", null);
addConsumer(1, 1, "queue0", null);
addConsumer(2, 2, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 1, true);
waitForBindings(2, "queues.testaddress", 1, 1, true);
waitForBindings(0, "queues.testaddress", 2, 2, false);
waitForBindings(1, "queues.testaddress", 2, 2, false);
waitForBindings(2, "queues.testaddress", 2, 2, false);
try {
sendWithProperty(1, "queues.testaddress", 1, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
// it should get the Retries on the latch
assertTrue(latch.await(10, TimeUnit.SECONDS));
} catch (Exception e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
}
use of org.apache.activemq.artemis.core.server.group.GroupingHandler in project activemq-artemis by apache.
the class ActiveMQServerImpl method deployGroupingHandlerConfiguration.
private void deployGroupingHandlerConfiguration(final GroupingHandlerConfiguration config) throws Exception {
if (config != null) {
GroupingHandler groupingHandler1;
if (config.getType() == GroupingHandlerConfiguration.TYPE.LOCAL) {
groupingHandler1 = new LocalGroupingHandler(executorFactory, scheduledPool, managementService, config.getName(), config.getAddress(), getStorageManager(), config.getTimeout(), config.getGroupTimeout(), config.getReaperPeriod());
} else {
groupingHandler1 = new RemoteGroupingHandler(executorFactory, managementService, config.getName(), config.getAddress(), config.getTimeout(), config.getGroupTimeout());
}
this.groupingHandler = groupingHandler1;
managementService.addNotificationListener(groupingHandler1);
}
}
Aggregations