What you want to do is possible using an interceptor like you've implemented. The broker even ships with a working example demonstrating a working MQTT interceptor. It's called "interceptor-client-mqtt".
Your interceptor code looks fine. Did you add it to your broker.xml? Justin On Thu, Dec 14, 2017 at 1:44 AM, Gupta Bharat <bharat.gu...@scania.com> wrote: > Hello, > > I want to intercept clients when trying to connect in order to do some > checks before allowing them to connect. > How could I add needed features to Artemis broker interceptor? Is this > possible in ActiveMQ? > > I have written following code which is not working on connecting the > activemq broker with MQTT client. > > import org.apache.activemq.artemis.api.core.ActiveMQException; > import org.apache.activemq.artemis.core.protocol.mqtt.MQTTInterceptor; > import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; > import org.apache.log4j.Logger; > > import io.netty.handler.codec.mqtt.MqttConnectMessage; > import io.netty.handler.codec.mqtt.MqttMessage; > > public class MyInterceptors implements MQTTInterceptor { > > final static Logger logger = Logger.getLogger(MyBroker.class); > > @Override > public boolean intercept(MqttMessage arg0, RemotingConnection arg1) > throws ActiveMQException { > > logger.info("MQTT Interceptor gets > called--------------------------------------------------------------"); > > > if (arg0 instanceof MqttConnectMessage) > { > logger.info("MQTT Interceptor gets > called--------------------------------------------------------------"); > } > return true; > > } > > } > > > > Regards, > Bharat Gupta > Development & Support | Platform Technician, IXCB | Scania IT > Mobile: +46700869007, +91-9718483802 > bharat.gu...@scania.com<mailto:bharat.gu...@scania.com> > >