Java 如何启用activemq插件

Java 如何启用activemq插件,java,plugins,activemq,interceptor,Java,Plugins,Activemq,Interceptor,我正在尝试为activemq(5.15.13)创建一个拦截器。 我使用来自的代码并将其编译为jar文件。 我将jar文件添加到/lib文件夹 然后我添加到activemq.xml 我明白了 jvm 1 | INFO |创建的LoggingBrokerPlugin:LoggingBrokerPlugin(logAll=true,logConnectionEvents=true,logSessionEvents=true,logConsumerEvents=false,logProducerEv

我正在尝试为activemq(5.15.13)创建一个拦截器。 我使用来自的代码并将其编译为jar文件。 我将jar文件添加到/lib文件夹

然后我添加到activemq.xml


我明白了

jvm 1 | INFO |创建的LoggingBrokerPlugin:LoggingBrokerPlugin(logAll=true,logConnectionEvents=true,logSessionEvents=true,logConsumerEvents=false,logProducerEvents=false,logTransactionEvents=false,logInternalEvents=false)

但是我的插件没有任何内容。。 如何注册和启用我的插件

package com.xxx.mqplugin;
导入java.util.logging.Logger;
导入org.apache.activemq.broker.broker;
导入org.apache.activemq.broker.BrokerFilter;
导入org.apache.activemq.broker.ConnectionContext;
导入org.apache.activemq.broker.region.MessageReference;
导入org.apache.activemq.command.ConnectionInfo;
导入org.apache.activemq.command.ProducerInfo;
导入org.apache.activemq.command.SessionInfo;
公共类MyBroker扩展了BrokerFilter{
公共MyBroker(下一个Broker){
超级(下一个);
}
public void addConnection(ConnectionContext上下文,ConnectionInfo信息)引发异常{
//你的密码在这里
System.out.println(“addConnection:+info.toString());
Logger.getLogger(“test”).info(“addConnection:+info.toString());
//然后给你父母打电话
super.addConnection(上下文、信息);
}
public void addSession(ConnectionContext上下文,SessionInfo信息)引发异常{
//你的密码在这里。。。
System.out.println(“addSession:+info.toString());
Logger.getLogger(“test”).info(“addSession:+info.toString());
//然后给你父母打电话
super.addSession(上下文、信息);
}
@凌驾
public void addProducer(ConnectionContext上下文,ProducerInfo信息)引发异常{
//你的密码在这里。。。
System.out.println(“addProducer:+info.toString());
Logger.getLogger(“test”).info(“addProducer:+info.toString());
super.addProducer(上下文、信息);
}
@凌驾
public void messageDelivered(ConnectionContext上下文,MessageReference MessageReference){
System.out.println(“messageDelivered:+messageReference.toString());
Logger.getLogger(“test”).info(“messageDelivered:+messageReference.toString());
super.messageDelivered(上下文、messageReference);
}
}
谢谢
您还需要实现一个“BrokerPlugin”对象,它是用于安装“BrokerFilter”实例的类型

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);
        }   

}
这就是您在代理XML配置中使用的类型

  <plugins>
      <bean xmlns="http://www.springframework.org/schema/beans" id="myPlugin" class="org.myorg.MyPlugin"/>    
  </plugins>


是的,我做了,但我没有看到任何类似于loggingBrokerPlugin的消息说插件已经安装在activemq启动时。(jvm 1 | INFO | Created LoggingBrokerPlugin:LoggingBrokerPlugin…)我是否必须将我的jar(mq-plugin-5.15.13.jar)放入apache-activemq-5.15.13\lib\?