`
三问飞絮
  • 浏览: 316464 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

开发ActiveMQ的插件BrokerPlugin

    博客分类:
  • Java
 
阅读更多

       两个步骤:参考地址:http://activemq.apache.org/interceptors.html

       1、开发插件类

                 插件类需要实现接口org.apache.activemq.broker.BrokerPlugin

                 activeMQ已有的实现类,如下

                 继承:org.apache.activemq.broker.BrokerPluginSupport=》BrokerFilter类=》BrokerPlugin接口

import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerPlugin;

public class MyPlugin implements BrokerPlugin {	
        
        public Broker installPlugin(Broker broker) throws Exception {            
             return new MyBroker(broker);
        }	

}

 

 

       2、配置activeMQ

  

 
<broker xmlns="http://activemq.org/config/1.0" brokerName="localhost" dataDirectory="${activemq.base}/data">

  <!-- The transport connectors ActiveMQ will listen to -->
  <transportConnectors>
     <transportConnector name="openwire" uri="tcp://localhost:61616" />
  </transportConnectors>

  <plugins>
      <bean id="myPlugin" class="org.myorg.MyPlugin"/>    
  </plugins>

 </broker>

 

 

======================

今天重新测试了一下,发现XML解析有问题,可是看activemq.xsd是OK的呀,也没有顺序才是。实现是想不出怎么做。完全按照教程上来的也解释有问题,可能是一个小细节或者包冲突导致。

      但是没有时间去细化问题,只想了一个绕过去的办法——本身activemq的配置文件是基于spring来实现的。那完全可以通过spring在broker实例化之前加上plugins配置信息。

 

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'bean'. One of '{"http://activemq.apache.org/schema/core":authorizationPlugin, "http://activemq.apache.org/schema/core":connectionDotFilePlugin, "http://activemq.apache.org/schema/core":destinationDotFilePlugin, "http://activemq.apache.org/schema/core":discardingDLQBrokerPlugin, "http://activemq.apache.org/schema/core":forcePersistencyModeBrokerPlugin, "http://activemq.apache.org/schema/core":jaasAuthenticationPlugin, "http://activemq.apache.org/schema/core":jaasCertificateAuthenticationPlugin, "http://activemq.apache.org/schema/core":jaasDualAuthenticationPlugin, "http://activemq.apache.org/schema/core":loggingBrokerPlugin, "http://activemq.apache.org/schema/core":multicastTraceBrokerPlugin, "http://activemq.apache.org/schema/core":simpleAuthenticationPlugin, "http://activemq.apache.org/schema/core":statisticsBrokerPlugin, "http://activemq.apache.org/schema/core":timeStampingBrokerPlugin, "http://activemq.apache.org/schema/core":traceBrokerPathPlugin, "http://activemq.apache.org/schema/core":udpTraceBrokerPlugin, WC[##other:"http://activemq.apache.org/schema/core"]}' is expected.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics