2016-06-29 100 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以外的一個)才能被攔截。