2016-06-29 101 views
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

回答

0

filled a feature request用于拦截器支持MQTT。它已经实施并在Artemis 1.4.0中发布。

在Artemis 1.3.0中,只有通过核心协议发送的消息(也可能是MQTT以外的一个)才能被拦截。