You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Massimiliano Cuccia <ma...@actwo.net> on 2018/04/16 11:03:16 UTC

camel and mqtt (ServiceMix)

Hi,
I would like to use Camel inside a ServiceMix project, I wrote a sample
bundle to test functionality BUT I have a problem consuming MQtt messages.

the task is in state "Active", but messages aren't received, I can see this
error in log file: "java.util.concurrent.TimeoutException: null"
what is this message referred to?
I don't understand what's going wrong
In the documentation seems so simple to achieve this task, but I can't
avoid this error.
Anyone already had similar problems?
Please reply with any useful advice.

I added to this email the log section and the xml of my test bundle and
other details


----------------------- Software versions
I'm running Karaf (4.2.0), Camel (2.20.0), camel-mqtt (2.20.0)
the MQtt broker is a Mosquitto 1.4.15 running in an Ubuntu 16.04.4 LTS
(working: tested using a python client)
the broker is fed by a python client that send messages every 5 seconds


----------------------- output of bundle:list

242 │ Active   │  80 │ 0.0.0                 │ maxc-rout.xml


----------------------- logfile

2018-04-16T12:21:29,958 | INFO  |
fileinstall-/home/ute/apache-karaf-4.2.0/deploy | fileinstall
       | 9 - org.apache.felix.fileinstall - 3.6.4 | Installing bundle
maxc-rout.xml / 0.0.0
2018-04-16T12:21:30,098 | INFO  | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | Attempting to start Camel Context camel-2
2018-04-16T12:21:30,100 | INFO  | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) is starting
2018-04-16T12:21:30,100 | INFO  | Blueprint Event Dispatcher: 1 |
ManagedManagementStrategy        | 51 - org.apache.camel.camel-core -
2.20.0 | JMX is enabled
2018-04-16T12:21:30,248 | INFO  | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | StreamCaching is not in use. If using streams then its recommended
to enable stream caching. See more details at
http://camel.apache.org/stream-caching.html
2018-04-16T12:21:30,274 | INFO  | Blueprint Event Dispatcher: 1 |
MQTTEndpoint                     | 206 - org.apache.camel.camel-mqtt -
2.20.0 | Connecting to tcp://192.168.3.200:1883 using 10 seconds timeout
2018-04-16T12:21:40,276 | INFO  | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) is shutting down
2018-04-16T12:21:40,281 | INFO  | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) uptime 10.182 seconds
2018-04-16T12:21:40,282 | INFO  | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) is shutdown in 0.006
seconds
2018-04-16T12:21:40,282 | ERROR | Blueprint Event Dispatcher: 1 |
BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
2.20.0 | Error occurred during starting Camel Context  camel-2
java.util.concurrent.TimeoutException: null
at org.fusesource.mqtt.client.Promise.await(Promise.java:83) ~[?:?]
at
org.apache.camel.component.mqtt.MQTTEndpoint.connect(MQTTEndpoint.java:342)
~[?:?]
at
org.apache.camel.component.mqtt.MQTTConsumer.doStart(MQTTConsumer.java:38)
~[?:?]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3688)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:4006)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3941)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3861)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3625)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3477)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:208)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3236)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3232)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3255)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3232)
~[51:org.apache.camel.camel-core:2.20.0]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3155)
~[51:org.apache.camel.camel-core:2.20.0]
at
org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:244)
~[49:org.apache.camel.camel-blueprint:2.20.0]
at
org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:284)
~[49:org.apache.camel.camel-blueprint:2.20.0]
at
org.apache.camel.blueprint.BlueprintCamelContext.blueprintEvent(BlueprintCamelContext.java:177)
[49:org.apache.camel.camel-blueprint:2.20.0]
at
org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:190)
[45:org.apache.aries.blueprint.core:1.9.0]
at
org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:188)
[45:org.apache.aries.blueprint.core:1.9.0]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[?:?]
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
2018-04-16T12:21:40,289 | INFO  |
fileinstall-/home/ute/apache-karaf-4.2.0/deploy | fileinstall
       | 9 - org.apache.felix.fileinstall - 3.6.4 | Started bundle:
blueprint:file:/home/ute/apache-karaf-4.2.0/deploy/maxc-rout.xml




----------------------- This is the bundle I deploy
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
  xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route id="route1">
      <from uri="mqtt:aaa?host=tcp://192.168.3.200:1883
&amp;subscribeTopicNames=test"/>
      <to uri="file:mqstream.out" />
    </route>
  </camelContext>
</blueprint>

----------------------- other bundle I tried
tested using & instead of &amp;
<from uri="mqtt:aaa?host=tcp://192.168.3.200:1883
&subscribeTopicNames=test"/>
tested using ; instead of &amp;
<from uri="mqtt:bbb?host=tcp://192.168.3.200:1883;subscribeTopicName=test"/>
tested using a public mqtt broker (produce random messages)
<from uri="mqtt:ttt?host=tcp://37.187.106.16:1883
;subscribeTopicName=temp/random"/>
and
<from uri="mqtt:ttt?host=tcp://37.187.106.16:1883
&amp;subscribeTopicName=temp/random"/>
and
<from uri="mqtt:ttt?host=tcp://37.187.106.16:1883"/>

none of these works
please help
--
MC//ac2

Re: camel and mqtt (ServiceMix)

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

It seems you get some kind of timeout.

You can also try the paho component for mqtt. It may be better as it
uses the Eclipse Paho library.
https://github.com/apache/camel/blob/master/components/camel-paho/src/main/docs/paho-component.adoc

On Mon, Apr 16, 2018 at 1:03 PM, Massimiliano Cuccia
<ma...@actwo.net> wrote:
> Hi,
> I would like to use Camel inside a ServiceMix project, I wrote a sample
> bundle to test functionality BUT I have a problem consuming MQtt messages.
>
> the task is in state "Active", but messages aren't received, I can see this
> error in log file: "java.util.concurrent.TimeoutException: null"
> what is this message referred to?
> I don't understand what's going wrong
> In the documentation seems so simple to achieve this task, but I can't
> avoid this error.
> Anyone already had similar problems?
> Please reply with any useful advice.
>
> I added to this email the log section and the xml of my test bundle and
> other details
>
>
> ----------------------- Software versions
> I'm running Karaf (4.2.0), Camel (2.20.0), camel-mqtt (2.20.0)
> the MQtt broker is a Mosquitto 1.4.15 running in an Ubuntu 16.04.4 LTS
> (working: tested using a python client)
> the broker is fed by a python client that send messages every 5 seconds
>
>
> ----------------------- output of bundle:list
>
> 242 │ Active   │  80 │ 0.0.0                 │ maxc-rout.xml
>
>
> ----------------------- logfile
>
> 2018-04-16T12:21:29,958 | INFO  |
> fileinstall-/home/ute/apache-karaf-4.2.0/deploy | fileinstall
>        | 9 - org.apache.felix.fileinstall - 3.6.4 | Installing bundle
> maxc-rout.xml / 0.0.0
> 2018-04-16T12:21:30,098 | INFO  | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | Attempting to start Camel Context camel-2
> 2018-04-16T12:21:30,100 | INFO  | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) is starting
> 2018-04-16T12:21:30,100 | INFO  | Blueprint Event Dispatcher: 1 |
> ManagedManagementStrategy        | 51 - org.apache.camel.camel-core -
> 2.20.0 | JMX is enabled
> 2018-04-16T12:21:30,248 | INFO  | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | StreamCaching is not in use. If using streams then its recommended
> to enable stream caching. See more details at
> http://camel.apache.org/stream-caching.html
> 2018-04-16T12:21:30,274 | INFO  | Blueprint Event Dispatcher: 1 |
> MQTTEndpoint                     | 206 - org.apache.camel.camel-mqtt -
> 2.20.0 | Connecting to tcp://192.168.3.200:1883 using 10 seconds timeout
> 2018-04-16T12:21:40,276 | INFO  | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) is shutting down
> 2018-04-16T12:21:40,281 | INFO  | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) uptime 10.182 seconds
> 2018-04-16T12:21:40,282 | INFO  | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | Apache Camel 2.20.0 (CamelContext: camel-2) is shutdown in 0.006
> seconds
> 2018-04-16T12:21:40,282 | ERROR | Blueprint Event Dispatcher: 1 |
> BlueprintCamelContext            | 49 - org.apache.camel.camel-blueprint -
> 2.20.0 | Error occurred during starting Camel Context  camel-2
> java.util.concurrent.TimeoutException: null
> at org.fusesource.mqtt.client.Promise.await(Promise.java:83) ~[?:?]
> at
> org.apache.camel.component.mqtt.MQTTEndpoint.connect(MQTTEndpoint.java:342)
> ~[?:?]
> at
> org.apache.camel.component.mqtt.MQTTConsumer.doStart(MQTTConsumer.java:38)
> ~[?:?]
> at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3688)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:4006)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3941)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3861)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3625)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3477)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:208)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3236)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3232)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3255)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3232)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3155)
> ~[51:org.apache.camel.camel-core:2.20.0]
> at
> org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:244)
> ~[49:org.apache.camel.camel-blueprint:2.20.0]
> at
> org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:284)
> ~[49:org.apache.camel.camel-blueprint:2.20.0]
> at
> org.apache.camel.blueprint.BlueprintCamelContext.blueprintEvent(BlueprintCamelContext.java:177)
> [49:org.apache.camel.camel-blueprint:2.20.0]
> at
> org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:190)
> [45:org.apache.aries.blueprint.core:1.9.0]
> at
> org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:188)
> [45:org.apache.aries.blueprint.core:1.9.0]
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> [?:?]
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> [?:?]
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
> [?:?]
> at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> [?:?]
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> [?:?]
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> [?:?]
> at java.lang.Thread.run(Thread.java:748) [?:?]
> 2018-04-16T12:21:40,289 | INFO  |
> fileinstall-/home/ute/apache-karaf-4.2.0/deploy | fileinstall
>        | 9 - org.apache.felix.fileinstall - 3.6.4 | Started bundle:
> blueprint:file:/home/ute/apache-karaf-4.2.0/deploy/maxc-rout.xml
>
>
>
>
> ----------------------- This is the bundle I deploy
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint
>   xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
>
>   <camelContext xmlns="http://camel.apache.org/schema/blueprint">
>     <route id="route1">
>       <from uri="mqtt:aaa?host=tcp://192.168.3.200:1883
> &amp;subscribeTopicNames=test"/>
>       <to uri="file:mqstream.out" />
>     </route>
>   </camelContext>
> </blueprint>
>
> ----------------------- other bundle I tried
> tested using & instead of &amp;
> <from uri="mqtt:aaa?host=tcp://192.168.3.200:1883
> &subscribeTopicNames=test"/>
> tested using ; instead of &amp;
> <from uri="mqtt:bbb?host=tcp://192.168.3.200:1883;subscribeTopicName=test"/>
> tested using a public mqtt broker (produce random messages)
> <from uri="mqtt:ttt?host=tcp://37.187.106.16:1883
> ;subscribeTopicName=temp/random"/>
> and
> <from uri="mqtt:ttt?host=tcp://37.187.106.16:1883
> &amp;subscribeTopicName=temp/random"/>
> and
> <from uri="mqtt:ttt?host=tcp://37.187.106.16:1883"/>
>
> none of these works
> please help
> --
> MC//ac2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2