ctron / kapua-gateway-client

A Gateway Client SDK for Eclipse Kapua™
Eclipse Public License 1.0
8 stars 3 forks source link

how to get commands from Kapua to a client #7

Open aycanvargun opened 6 years ago

aycanvargun commented 6 years ago

Hi again,

I can send data to my Kapua from the FuseClient now.

(1) But I want to get commands from Kapua to my Fuse Client (named soap8). I don't know how. (2) In Kapua, I created a job (named job1). I added a step (named step1) (3) Inside, i added a command as 'echo "123"'. I want to get this command to my Fuse Client (named soap8) from my Kapua.

picture

I subscribed to "my receiver" topic in Java code. But, Is there any special topic for commands? In the java code, i don't now how to get the command from Kapua. Could you please help me? In addition, In the constructor of FuseClient.java,

this.connection = connection; connection.listener(this.listener); connection.connect(new Promise<>());

Do i need this.listener in this.connection ? Do i have to change the code?

Thank you.

ctron commented 6 years ago

The kapua gateway client allows you to receive messages like in the exampe: https://github.com/ctron/kapua-gateway-client/blob/master/gateway-client-profile-kura/src/test/java/org/eclipse/kapua/gateway/client/KuraExample.java#L45

aycanvargun commented 6 years ago

I subscribed to a topic ("receiver") and wait for the connection, I get error from broker container logs,

07:33:09.392 [ActiveMQ NIO Worker 4] WARN o.a.a.t.m.s.AbstractMQTTSubscriptionStrategy - Error subscribing to acme123/soap9/app1/my/receiver java.lang.SecurityException: User user123 (soap9 - tcp://217.78.106.69:56486 - conn id 600724459434597600) is not authorized to read from: Consumer.8,539,744,234,403,289,497:soap9:AT_LEAST_ONCE.VirtualTopic.acme123.soap9.app1.my.receiver

I subscribed to the topic ("sender") that I created, I get error from broker container logs,

[Camel (camelContext) thread #17 - JmsConsumer[Consumer.eurotech:mainRoutelisteners:EXACTLY_ONCE.VirtualTopic.%3E]] WARN eclipselink.logging.all - Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.OptimisticLockException Exception Description: The object [org.eclipse.kapua.service.device.registry.internal.DeviceImpl@7e72d798[tagIds={[]},groupId=null>,clientId=soap9,connectionId=600724459434597600,connection=org.eclipse.kapua.service.device.registry.connection.internal.DeviceConnectionImpl@a1061e2,status=ENABLED,displayName=<null,lastEventId=4757100873288453679,lastEvent=org.eclipse.kapua.service.device.registry.event.internal.DeviceEventImpl@4db71c89,serialNumber=,modelId=,imei=,imsi=,iccid=,biosVersion=,firmwareVersion=,osVersion=10.0,jvmVersion=1.8.0_181,osgiFrameworkVersion=,applicationFrameworkVersion=,connectionInterface=,connectionIp=,applicationIdentifiers=,acceptEncoding=,customAttribute1=,customAttribute2=,customAttribute3=,customAttribute4=,customAttribute5=,modifiedOn=Tue Nov 20 07:28:05 UTC 2018,modifiedBy=917791760301272189,optlock=5,attributes=,properties=,id=2278622550366941087,scopeId=8539744234403289497,createdOn=Tue Nov 20 07:22:01 UTC 2018,createdBy=917791760301272189]] cannot be updated because it has changed or been deleted since it was last read. Class> org.eclipse.kapua.service.device.registry.internal.DeviceImpl Primary Key> 2,278,622,550,366,941,087 07:28:05.081 [Camel (camelContext) thread #17 - JmsConsumer[Consumer.eurotech:mainRoutelisteners:EXACTLY_ONCE.VirtualTopic.%3E]] ERROR o.e.k.b.c.l.DeviceMessageListener - Error while processing device birth life-cycle event org.eclipse.kapua.KapuaOptimisticLockingException: The entity is out of state as it has been modified or deleted by another transaction.

ctron commented 6 years ago

Both problems look like an issue in Kapua, and less like an issue in the gateway client to me.

Maybe you can ask a question about that on the kapua-dev mailing list, or on the eclipse/kapua project on GitHub.

aycanvargun commented 6 years ago

Ok, I will as. Thank you.

Kind Regards.