Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » [kura 4.1.0]Problems with CloudSubscriber(onMessageArrived method not works)
[kura 4.1.0]Problems with CloudSubscriber [message #1807606] Tue, 04 June 2019 14:36 Go to next message
giuseppe ferro is currently offline giuseppe ferroFriend
Messages: 34
Registered: August 2016
Member
Hi all,
I need help.
I'm testing Demo Heater kura bundle.
in particular I want to add.implement and test the CloudSubscriber.
see attached code:

public class Heater implements ConfigurableComponent, CloudSubscriberListener, CloudConnectionListener, CloudDeliveryListener {
.............
private CloudSubscriber cloudSubscriber;
.........
public void setCloudSubscriber(CloudSubscriber cloudSubscriber) {
this.cloudSubscriber = cloudSubscriber;
this.cloudSubscriber.registerCloudSubscriberListener(Heater.this);
this.cloudSubscriber.registerCloudConnectionListener(Heater.this);
}

public void unsetCloudSubscriber(CloudSubscriber cloudSubscriber) {
this.cloudSubscriber.unregisterCloudSubscriberListener(Heater.this);
this.cloudSubscriber.unregisterCloudConnectionListener(Heater.this);
this.cloudSubscriber = null;
}

...........

@Override
public void onMessageArrived(KuraMessage message) {
logReceivedMessage(message);
logger.debug("//////////////// OnReceivedMessage ///////////////////");
}

I have create on kura 4.1.0 one publisher and one subscriber. The topic is the same so i can publish into a topic and "listen" from the same topic.
but i can't read or receive correctly the message published.

I attached the following kura.log:

2019-06-04T14:20:33,249 [] INFO o.e.k.c.d.DataServiceImpl - Storing message on topic: #account-name/#client-id/realtime/command, priority: 7
2019-06-04T14:20:33,256 [] DEBUG o.e.k.c.d.s.DbDataStore - Store message count: 93
2019-06-04T14:20:33,264 [] INFO o.e.k.c.d.DataServiceImpl - Stored message on topic: #account-name/#client-id/realtime/command, priority: 7
2019-06-04T14:20:33,269 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.DataServiceImpl - Publishing message with ID: 81398 on topic: #account-name/#client-id/realtime/command, priority: 7
2019-06-04T14:20:33,272 [] INFO o.e.k.d.h.Heater - Published message: org.eclipse.kura.message.KuraPayload@15295e3
2019-06-04T14:20:33,287 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.t.m.MqttDataTransport - Replaced tokens in topic #account-name/#client-id/realtime/command with: /GK400001116GH1/realtime/command
2019-06-04T14:20:33,291 [DataServiceImpl:Submit] INFO o.e.k.c.d.t.m.MqttDataTransport - Publishing message on topic: /GK400001116GH1/realtime/command with QoS: 1
2019-06-04T14:20:33,299 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.t.m.MqttDataTransport - Delivery complete for message with ID: 15863
2019-06-04T14:20:33,302 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.t.m.DataTransportListenerS - No registered listener services. Ignoring onMessageConfirmed
2019-06-04T14:20:33,310 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.t.m.MqttDataTransport - Published message with ID: 15863
2019-06-04T14:20:33,317 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.DataServiceImpl - Published message with ID: 81398 and MQTT message ID: 15863
2019-06-04T14:20:33,319 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.DataServiceImpl - Confirmed message with MQTT message ID: 15863 on session ID: GK400001116GH1-tcp://xxx.xxx.xxx.xxx:1886
2019-06-04T14:20:33,321 [MQTT Call: GK400001116GH1] INFO o.e.k.c.d.DataServiceImpl - Confirmed message ID: 81398 to store
2019-06-04T14:20:33,326 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.DataServiceListenerS - No registered listener services. Ignoring onMessagePublished
2019-06-04T14:20:33,335 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.DataServiceImpl - Suspending publishing thread indefinitely
2019-06-04T14:20:33,339 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.DataServiceListenerS - No registered listener services. Ignoring onMessageConfirmed
2019-06-04T14:20:33,342 [pool-79-thread-4] INFO o.e.k.d.h.Heater - Confirmed message with id: 81398
2019-06-04T14:20:33,346 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.DataServiceImpl - Suspending publishing thread indefinitely
2019-06-04T14:20:33,348 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.t.m.MqttDataTransport - Message arrived on topic: /GK400001116GH1/realtime/command
2019-06-04T14:20:33,350 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.t.m.DataTransportListenerS - No registered listener services. Ignoring onMessageArrived
2019-06-04T14:20:33,352 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.DataServiceImpl - Message arrived on topic: /GK400001116GH1/realtime/command
2019-06-04T14:20:33,354 [MQTT Call: GK400001116GH1] DEBUG o.e.k.c.d.DataServiceListenerS - No registered listener services. Ignoring onMessageArrived
2019-06-04T14:20:33,356 [MQTT Call: GK400001116GH1] INFO o.e.k.c.c.CloudServiceImpl - Message arrived on topic: /GK400001116GH1/realtime/command
2019-06-04T14:20:33,361 [DataServiceImpl:Submit] DEBUG o.e.k.c.d.DataServiceImpl - Suspending publishing thread indefinitely

I'm expecting the Logger String on the following Callback
@Override
public void onMessageArrived(KuraMessage message) {
logReceivedMessage(message);
logger.debug("//////////////// OnReceivedMessage ///////////////////");
}

I have attached two pictures of Kura WEB UI configuration

Can someone help me?
thanks a lot
Bye
Giuseppe
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807616 is a reply to message #1807606] Wed, 05 June 2019 07:05 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
Maybe try to replicate what done for the example publisher: https://github.com/eclipse/kura/tree/develop/kura/examples/org.eclipse.kura.example.publisher

Best regards,
Matteo
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807617 is a reply to message #1807616] Wed, 05 June 2019 07:23 Go to previous messageGo to next message
giuseppe ferro is currently offline giuseppe ferroFriend
Messages: 34
Registered: August 2016
Member
Hi Matteo,
thanks for your reply.

To add the Subscriber, I have modified Demo Heater using example publisher..
by the way, I have install example publisher from kura eclipse Marketplace but seems don't work

tail -f /var/log/kura.log
2019-06-05T07:14:22,973 [qtp9715618-72] INFO o.e.k.c.c.ConfigurationServiceImpl - Registering metatype pid: org.eclipse.kura.example.publisher.ExamplePublisher ...

It's the only output in kura
i have the same output if I import project from github ,create dp package and install into bbb

what am I doing wrong?
Thanks
Giuseppe
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807618 is a reply to message #1807617] Wed, 05 June 2019 07:25 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Compared to the heater that is a singleton component that has a single instance that automatically starts, the example publisher is a factory. To instantiate it, you need to use the + button on the left, select the example publisher factory and provide a name. It will create a new instance that will be listed in the services section of the web UI.

Best regards,
Matteo
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807622 is a reply to message #1807618] Wed, 05 June 2019 10:09 Go to previous messageGo to next message
giuseppe ferro is currently offline giuseppe ferroFriend
Messages: 34
Registered: August 2016
Member
You are right but nothing is changed.
see files attached.

the method
private void logReceivedMessage(KuraMessage msg)
never shows up when message arrives on topic.

Thanks a lot for your attention and quick answer
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807623 is a reply to message #1807622] Wed, 05 June 2019 10:13 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Is the cloud connection subscriber properly configured?

Best regards,
Matteo
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807624 is a reply to message #1807623] Wed, 05 June 2019 10:32 Go to previous messageGo to next message
giuseppe ferro is currently offline giuseppe ferroFriend
Messages: 34
Registered: August 2016
Member
Yes.
I follow this guide
https://eclipse.github.io/kura/cloud-api/3-app-dev-guide.html
--"The CloudSubscriber will invoke the onMessageArrived() method when new messages are received"-- this method (callback) is never invoked
-- "The CloudSubscriber will invoke the onMessageConfirmed() method when a published message is confirmed."-- OK
from the files attached previously you can see all the parameters of CloudSubscriber an Publisher.

Moreover I use the default example publisher from market place.
the kura log seems to be Ok. i have no exception or error.

Is it possible that i need a Kura bundle for Subscribe and an other Kura bundle for Publish?
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807633 is a reply to message #1807624] Wed, 05 June 2019 11:36 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
What is the configuration of the "heaterSubscriber" component?
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807634 is a reply to message #1807633] Wed, 05 June 2019 11:48 Go to previous messageGo to next message
giuseppe ferro is currently offline giuseppe ferroFriend
Messages: 34
Registered: August 2016
Member
Application Id: realtime/command
Application Topic: (empty)
Qos: 1
Kind of Message: Data
Re: [kura 4.1.0]Problems with CloudSubscriber [message #1807886 is a reply to message #1807634] Tue, 11 June 2019 14:17 Go to previous message
giuseppe ferro is currently offline giuseppe ferroFriend
Messages: 34
Registered: August 2016
Member
Hi Matteo,
I was able to setup correctly the CloudSuscriber.
It is mandatory to fill Topic Context Account-Name in MqttDataTransport

Thanks for your time
Previous Topic:Send data from raspberry and read them from PC
Next Topic:KuraPayload body
Goto Forum:
  


Current Time: Fri Dec 13 19:35:24 GMT 2024

Powered by FUDForum. Page generated in 0.03880 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top