activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From linlinxiao <84226...@qq.com>
Subject How to implement a custom policy?
Date Wed, 13 Sep 2017 06:45:34 GMT
1.I wrote a java file extends SimpleDispatchPolicy in the
org.apache.activemq.broker.region.policy package
2.Make the Maven compilation packaged under the parent project

But this custom policy is not generated in the activemq-spring/activemq.xsd
file 
<http://activemq.2283324.n4.nabble.com/file/t378583/WX20170913-144008%402x.png> 

Java code:

public class SimpleMqttDispatchPolicy extends SimpleDispatchPolicy {

	private static final Log LOG =
LogFactory.getLog(SimpleMqttDispatchPolicy.class);

	
	private static final String P2P_TAG = "P2P";

	
	@Override
	public boolean dispatch(MessageReference node, MessageEvaluationContext
msgContext, List<Subscription> consumers)
			throws Exception {
		boolean flag = false;
		
		ActiveMQDestination desination = node.getMessage().getDestination();
		
		// String topicUrl = desination.getQualifiedName();
		
		String topic = desination.getPhysicalName();
		String clientId = parseClientId4Topic(topic);
		if (null != clientId && !"".equals(clientId)) {
			LOG.info("=================Client id:" + clientId);
			// p2p
			flag = p2pProccess(consumers, node, clientId, desination, msgContext);
		} else {
			flag = super.dispatch(node, msgContext, consumers);
		}
		return flag;
	}
}

How the simpleDispatchPolicy in the activemq.xsd file is generated, how do I
customize a policy´╝č
Someone helped me?



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-Dev-f2368404.html

Mime
View raw message