*Hello * I want to customize policy in active MQ。 *1*.Write
Java class extends SimpleDispatchPolicy in package
org.apache.activemq.broker.region.policy.Implement custom business logic in
this java file. e.g.: public class P2pDispatchPolicy extends
SimpleDispatchPolicy { private static final Log LOG =
LogFactory.getLog(P2pDispatchPolicy.class); /** * p2p */ private
static
final String P2P_TAG = "P2P/"; @Override public boolean
dispatch(MessageReference node, MessageEvaluationContext msgContext, List
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); //
flag =
p2pProccess(consumers, node, clientId, desination, msgContext); } else
{
flag = super.dispatch(node, msgContext, consumers); }
return flag; }
2.In active.xml configuration:
" >
P2P.>">
The DispatchPolicy part is my custom. *3.* Start ActiveMQ,but I got
the following error message: Caused by: org.xml.sax.SAXParseException;
lineNumber: 85; columnNumber: 38; cvc-complex-type.2.4.a: 发现了以元素
'p2pDispatchPolicy' 开头的无效内容。应以
'{"http://activemq.apache.org/schema/core":priorityDispatchPolicy,
"http://activemq.apache.org/schema/core":priorityNetworkDispatchPolicy,
"http://activemq.apache.org/schema/core":roundRobinDispatchPolicy,
"http://activemq.apache.org/schema/core":simpleDispatchPolicy,
"http://activemq.apache.org/schema/core":strictOrderDispatchPolicy,
WC[##other:"http://activemq.apache.org/schema/core"]}' 之一开头 In
addition, I try to skip the XML schema validation,and using :./activemq
console xbean:../conf/activemq.xml?validate=false command start
activemq,You still get the error message: ERROR:
org.springframework.beans.factory.BeanDefinitionStoreException: Unrecognized
xbean element mapping: p2pDispatchPolicy in namespace
http://activemq.apache.org/schema/coreorg.springframework.beans.factory.BeanDefinitionStoreException:
Unrecognized xbean element mapping: p2pDispatchPolicy in namespace
http://activemq.apache.org/schema/core No information on the custom
policy has been found on the official website,Does anyone help me,thanks.
--
View this message in context:
http://activemq.2283324.n4.nabble.com/How-do-you-customize-policy-in-ActiveMQ-for-topic-tp4728785.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.