|
|
Re: MQTT Request/Response in camel [message #1801308 is a reply to message #1801304] |
Wed, 16 January 2019 13:30 |
Aistis Kaikaris Messages: 33 Registered: March 2018 |
Member |
|
|
Matteo Maiero wrote on Wed, 16 January 2019 13:28Are you using control topics
Hi,
I'm not really sure, the page in question does not seem to mention what control topics are, so i assumed that the example in the kura page:
$EDC/guest/F0:DE:F1:C4:53:DB/CONF-V1/GET/configurations
is a control topic. I thought that 'CONF-V1' was a kura service that listens for the 'configurations' topic. Is this just a mock example and not a real service which listens to the 'configurations' topic?
I also forgot to add the account name, so i changed the topic from:
$EDC/test-gateway/CONF-V1/GET/configurations
to
"$EDC/Lamps/test-gateway/CONF-V1/GET/configurations"
But this still does not get any response.
[Updated on: Wed, 16 January 2019 13:35] Report message to a moderator
|
|
|
Re: MQTT Request/Response in camel [message #1801335 is a reply to message #1801308] |
Thu, 17 January 2019 05:44 |
Aistis Kaikaris Messages: 33 Registered: March 2018 |
Member |
|
|
So a few additional observations.
1) I tried using https://github.com/amitjoy/Kura-MQTT-Client-Utility to publish with the same topic and subscribe to the same topic as my original post and it worked.
2) When i send the message with camel, it gets stored in kapua data and does not seem to reach the kura device (at least i can't see it in the kura log)
3) The topic i write into the camel route gets appended by the camel cloud component with additional information.
So in route i write:
$EDC/Lamps/test-gateway/CONF-V1/GET/configurations
Which then i sent as:
Lamps/DemoEclipseLampNode/$EDC/Lamps/test-gateway/CONF-V1/GET/configurations
So it appends my eclipse instance (which i'm sending the message from) client id and account on top of the message that i write. Is this how it is supposed to work?
[Updated on: Thu, 17 January 2019 06:41] Report message to a moderator
|
|
|
Re: MQTT Request/Response in camel [message #1801340 is a reply to message #1801335] |
Thu, 17 January 2019 08:52 |
Aistis Kaikaris Messages: 33 Registered: March 2018 |
Member |
|
|
UPDATE:
I might have figured out the problem. Still need to do some testing, but i got a 200 response. The problem is that the camel component searches for client_id and other headers, and if it does not find them, it appends them, so i did:
My routbuilder:
public class CommunicationRoute extends RouteBuilder{
private PayLoadConstructor payloadConstructor;
public CommunicationRoute() {
this.veryGood= new VeryGood();
this.payloadConstructor = new PayLoadConstructor();
}
@Override
public void configure() throws Exception {
from("timer://heartbeat?fixedRate=true&period=100000").id("send_route")
.process(this.payloadConstructor)
.log("${headers}")
.to("kura-cloud:CONF-V1/GET/configurations");
from("kura-cloud:CONF-V1/REPLY/REQUEST_7RRBNIBVB0045TPM20VRQB1TNH").id("recieve_route")
.log("${headers}")
.log("${body}");
}
}
My PayloadBuilder:
public class PayLoadConstructor implements Processor{
public void process(Exchange exchange) throws Exception {
final KuraPayload kuraPayload = new KuraPayload();
kuraPayload.setTimestamp(new Date());
exchange.getIn().setHeader(KuraCloudClientConstants.CAMEL_KURA_CLOUD_CONTROL, true);
exchange.getIn().setHeader(KuraCloudClientConstants.CAMEL_KURA_CLOUD_DEVICEID, "test-gateway");
kuraPayload.addMetric("request.id", "REQUEST_7RRBNIBVB0045TPM20VRQB1TNH");
kuraPayload.addMetric("requester.client.id", "DemoEclipseLampNode");
exchange.getIn().setBody(kuraPayload);
}
}
Now it appends the headers that i put inside the exchange. 'KuraCloudClientConstants.CAMEL_KURA_CLOUD_CONTROL' appends $EDC, 'KuraCloudClientConstants.CAMEL_KURA_CLOUD_DEVICEID' appends the smartnode i'm sending this message to. Now the topic gets created correctly. This is the source code which appends the headers to the topic:
https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-kura/src/main/java/io/rhiot/component/kura/cloud/KuraCloudProducer.java
[Updated on: Thu, 17 January 2019 08:57] Report message to a moderator
|
|
|
|
Re: MQTT Request/Response in camel [message #1801363 is a reply to message #1801351] |
Thu, 17 January 2019 13:33 |
Aistis Kaikaris Messages: 33 Registered: March 2018 |
Member |
|
|
Pierantonio Merlino wrote on Thu, 17 January 2019 13:09Hi,
I try to understand what is your use-case, but there are some details missing...
Could you please explain what you're trying to achieve?
Best,
Pier
Hi
I was trying to familiarize myself with mqtt kura cloud communication.
I have two test kura devices and one kapua instance running.
First kura device has a camel mqtt publisher and subscriber routes.
First kura device sends an CONF-1 (or one of the examples in the kura webpage) mqtt request via camel route to the second device.
I was trying to get a response with the subscriber, which i eventually got when i made the changes in my former post. After the changes i get reponse header '200' and a body.
Now i'm trying to figure out how to decode the response body, which from what i understand is encoded with google protobuf.
[Updated on: Thu, 17 January 2019 13:34] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.09245 seconds