[ 
https://issues.apache.org/jira/browse/CAMEL-5411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13403895#comment-13403895
 ] 

Ralf Kornberger commented on CAMEL-5411:
----------------------------------------

I use Camel to fetch a Message (XML, Protobuf, ...) from the Broker. Using 
Camel-MQTT, as it is, the message is fetched, but the body still includes the 
MQTT header (topic and binary stuff before) which I don't want. I only want the 
payload (=my xml or protobuf stuff). 
Here is an example:

I sent the String 'Test123' via MQTT to Camel. Using the example code from your 
website 


 
from("mqtt:bar?subscribeTopicName=test.mqtt.topic").transform(body().convertToString()).bean
 (myProcessingBean);

I expect body to be 'Test123'. But instead body is something like 
'0�^C^@^Ktest.mqtt.topicTest123' (the stuff before test.mqtt.topic are 
nonprintable chars).
So the body is the whole MQTT message instead of just the payload. I makes no 
sense to have the full MQTT message as body here because you can't really 
decode/spilt it well
without going deeply into the MQTT implemenation of the the MQTT Client (from 
org.fusesource.mqtt-client in my case). 
But when you apply the patch, it (in my opinion) sets body corretly to 
'Test123'.







                
> MQTT Endpoint does not correctly return the MQTT-Payload
> --------------------------------------------------------
>
>                 Key: CAMEL-5411
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5411
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mqtt
>    Affects Versions: 2.10.0, 2.10.1, 2.11
>         Environment: Linux 64bit, JDK 1.6, Mosquitto MQTT Broker
>            Reporter: Ralf Kornberger
>         Attachments: MQTTEndpoint.java.patch
>
>
> MQTT Endpoint does not correctly return the MQTT-Payload. It returns the 
> whole MQTT Message (header + payload).
> The bug is in line 89 of MQTTEndpoint.java (version 2.11, but also in 2.10)
>  exchange.getIn().setBody(body.getData());
> must become
>  exchange.getIn().setBody(body.toByteArray()); 
> because getData() ignores the offset (to skip the MQTT header) set in the 
> body byte array.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to