my activemq plugin not work -
i write activemq plugin, not work.
the code:
package cn.ennwifi.mqttplugin; import org.apache.activemq.broker.broker; import org.apache.activemq.broker.brokerplugin; public class mqttplugin implements brokerplugin { public broker installplugin(broker broker) throws exception { return new mqttfilter(broker); } } package cn.ennwifi.mqttplugin; import org.apache.activemq.broker.broker; import org.apache.activemq.broker.brokerfilter; import org.apache.activemq.broker.connectioncontext; import org.apache.activemq.command.connectioninfo; public class mqttfilter extends brokerfilter { public mqttfilter(broker broker) { super(broker); system.out.println("mqtt插件"); } @override public void addconnection(connectioncontext context, connectioninfo info) throws exception { system.out.println("mqtt连接信息:" + info.getclientid()); if (info.getusername() != "123") { return; } super.addconnection(context, info); } }
the configure:
<plugins> <bean xmlns="http://www.springframework.org/schema/beans" id="myplugin" class="cn.ennwifi.mqttplugin.mqttplugin"/> </plugins>
i used mvn:clean package pack jar,put activemq/lib version 5.14.1
i change code
if (info.getusername() == null) { throw new exception("用户名不能为空"); }
i used throw exception replace return.
Comments
Post a Comment