1
有人能指导我如何拦截ActiveMQ Artemis经纪人上的mqtt消息吗?我尝试了手册中的建议,但mqtt消息不拦截。然而,发布和订阅消息正常。在artemis中拦截mqtt消息
拦截类:
public class InterceptorExample implements Interceptor {
@Override
public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException {
System.out.println("Packet intercepted");
return true;
}
}
我拦截器添加到addMQTTConnector方法配置
protected void addMQTTConnector() throws Exception {
.
.
.
List<String> incomingInterceptors = new ArrayList<>();
incomingInterceptors.add("org.apache.activemq.artemis.core.protocol.mqtt.InterceptorExample");
server.getConfiguration().setIncomingInterceptorClassNames(incomingInterceptors);
}
为代理类全码是在https://codeshare.io/snZsB