You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Abhishek <ak...@gmail.com> on 2016/11/09 17:13:09 UTC

Re: How to enable MQTT in TomEE ?

hasalex wrote
> It works !
> 
> I've added this piece of configuration in the tomee.xml file :
> 
>     
> <Resource id="MqttResourceAdapter" type="ActiveMQResourceAdapter">
>         BrokerXmlConfig =  broker:(mqtt://localhost:1883)
>     
> </Resource>
> 	
> 
> Then I've added mqtt-client-1.6.jar and activemq-mqtt-5.9.0.jar files into
> TomEE's lib directory.

Hi,

I am trying to enable MQTT in Apache TomEE 7.0.1. I have updated tomee.xml
with below contents
  <Resource id="MQTTResourceAdapter" type="ActiveMQResourceAdapter">
      BrokerXmlConfig =
broker:(mqtt://localhost:1883)?useJmx=false&amp;persistent=false    
  </Resource>

I also added the activemq-mqtt-5.13.3.jar and other dependencies to
tomee/lib

But when I run my Maven project on TomEE (Windows 10) following message is
displayed

/WARNING - Exception occurred processing: 
MQTTFrame { type: unknown, qos: AT_MOST_ONCE, dup:false }:
org.apache.activemq.transport.mqtt.MQTTProtocolException: Unknown MQTTFrame
type: 0/

In the code when I try to create the connection then exception is thrown.

Code:
/ConnectionFactory factory = new
ActiveMQConnectionFactory("tcp://localhost:1883");
Connection connection = factory.createConnection();
connection.start();/

Exception:
*javax.jms.JMSException: Cannot send, channel has already failed:
tcp://127.0.0.1:1883*
	at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)
	at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1407)
	at
org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1496)
	at
org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:523)


Since there was a thread on this topic I posted here. If required I will
start a new thread.

Thanks,
Abhishek






--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/How-to-enable-MQTT-in-TomEE-tp4666817p4680509.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: How to enable MQTT in TomEE ?

Posted by Abhishek <ak...@gmail.com>.
Hi Romain,

Thanks for the reply. I was able to enable MQTT with code instead of
configuration. In my WAR I added a ServletContextListener (@WebListener) and
in the contextInitialized() I added these 3 lines:

/
brokerService = new BrokerService();
brokerService.addConnector("mqtt://0.0.0.0:1883");
brokerService.start()/

In the contextDestroyed():
/brokerService.stop();/

This added the required connector and is sufficient for the POC I am working
on . I will work on fixing my configuration later if required. I will create
a new thread for that if I cannot get it working. 

Abhishek



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/How-to-enable-MQTT-in-TomEE-tp4666817p4680522.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: How to enable MQTT in TomEE ?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Abhishek,

yes another thread is probably better and will need a sample project to
reproduce it.

Side note: did you already checked you don't do that
http://activemq.2283324.n4.nabble.com/MQTTFrame-unknown-td4697966.html ?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-11-09 18:13 GMT+01:00 Abhishek <ak...@gmail.com>:

> hasalex wrote
> > It works !
> >
> > I've added this piece of configuration in the tomee.xml file :
> >
> >
> > <Resource id="MqttResourceAdapter" type="ActiveMQResourceAdapter">
> >         BrokerXmlConfig =  broker:(mqtt://localhost:1883)
> >
> > </Resource>
> >
> >
> > Then I've added mqtt-client-1.6.jar and activemq-mqtt-5.9.0.jar files
> into
> > TomEE's lib directory.
>
> Hi,
>
> I am trying to enable MQTT in Apache TomEE 7.0.1. I have updated tomee.xml
> with below contents
>   <Resource id="MQTTResourceAdapter" type="ActiveMQResourceAdapter">
>       BrokerXmlConfig =
> broker:(mqtt://localhost:1883)?useJmx=false&amp;persistent=false
>   </Resource>
>
> I also added the activemq-mqtt-5.13.3.jar and other dependencies to
> tomee/lib
>
> But when I run my Maven project on TomEE (Windows 10) following message is
> displayed
>
> /WARNING - Exception occurred processing:
> MQTTFrame { type: unknown, qos: AT_MOST_ONCE, dup:false }:
> org.apache.activemq.transport.mqtt.MQTTProtocolException: Unknown
> MQTTFrame
> type: 0/
>
> In the code when I try to create the connection then exception is thrown.
>
> Code:
> /ConnectionFactory factory = new
> ActiveMQConnectionFactory("tcp://localhost:1883");
> Connection connection = factory.createConnection();
> connection.start();/
>
> Exception:
> *javax.jms.JMSException: Cannot send, channel has already failed:
> tcp://127.0.0.1:1883*
>         at
> org.apache.activemq.util.JMSExceptionSupport.create(
> JMSExceptionSupport.java:72)
>         at
> org.apache.activemq.ActiveMQConnection.syncSendPacket(
> ActiveMQConnection.java:1407)
>         at
> org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(
> ActiveMQConnection.java:1496)
>         at
> org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:523)
>
>
> Since there was a thread on this topic I posted here. If required I will
> start a new thread.
>
> Thanks,
> Abhishek
>
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/How-to-enable-MQTT-in-TomEE-tp4666817p4680509.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>