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