[no jira] add replay policy to draining broker to allow drain to origin

This commit is contained in:
gtully 2016-11-11 12:01:54 +00:00
parent 7d0df2d01e
commit 9d6bc3a5d8
1 changed files with 13 additions and 0 deletions

View File

@ -18,6 +18,8 @@ package org.apache.activemq.network;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
@ -45,6 +47,17 @@ public class DrainBridgeTest {
NetworkConnector drainingNetworkConnector = drainingBroker.addNetworkConnector("static:(" + target.getTransportConnectorByScheme("tcp").getPublishableConnectString() + ")");
drainingNetworkConnector.setStaticBridge(true);
drainingNetworkConnector.setStaticallyIncludedDestinations(Arrays.asList(new ActiveMQDestination[]{new ActiveMQQueue("*")}));
// ensure replay back to the origin is allowed
PolicyMap policyMap = new PolicyMap();
PolicyEntry defaultEntry = new PolicyEntry();
defaultEntry.setExpireMessagesPeriod(0);
ConditionalNetworkBridgeFilterFactory filterFactory = new ConditionalNetworkBridgeFilterFactory();
filterFactory.setReplayWhenNoConsumers(true);
defaultEntry.setNetworkBridgeFilterFactory(filterFactory);
policyMap.setDefaultEntry(defaultEntry); // applies to all destinations
drainingBroker.setDestinationPolicy(policyMap);
drainingBroker.start();
System.out.println("Local count: " + drainingBroker.getAdminView().getTotalMessageCount() + ", target count:" + target.getAdminView().getTotalMessageCount());