cancel
Showing results for 
Search instead for 
Did you mean: 

New entry in hana table send using websocket

collinjona
Explorer
0 Kudos

Dear All,

I would like to know if it's possible when I have a new entry in my hana table to send this entry with websocket ?

If yes how to do it ? (Java application or XS app )?

Thanks and regards

anton_levin
Advisor
Advisor
0 Kudos

Hello Jonathan,

if I understood your question correctly, you are using "Internet of Things for Neo environment" [1] where you have your IoT Message Type configured and the Device is sending messages to the IoT MMS using that defined format. Now you want to extend your Message Type with an additional field and would like your existing T_IOT_ table also be extended, right?

Please elaborate a bit.

Regards,

Anton

[1] https://help.sap.com/viewer/product/SAP_CP_IOT_2.0/Cloud/en-US

collinjona
Explorer
0 Kudos

Hi Anton,

Yes I'm using IOT to receive message and store it in my an HANA table this part work correctly.
But now that I want is, when I receive a new message from my IOT device, publish throught a websocket the new message stored in my table.

Is it more clear?

Thanks for your help 🙂

anton_levin
Advisor
Advisor
0 Kudos

Could you please rephrase this sentence "But now that I want is, when I receive a new message from my IOT device, publish throught a websocket the new message stored in my table." in other words please?

collinjona
Explorer
0 Kudos

Sorry Anton 🙂

Actually I receive message from different IOT device and the data sent are stored in my table on HANA.

My goal is: when a new entry on on my table is performed I want to publish this new entry throught a websocket

Accepted Solutions (0)

Answers (1)

Answers (1)

anton_levin
Advisor
Advisor

Hello Jonathan,

so, based on your additional comments above, the use case you describe is: react on incoming messages from the device (new entries in the table) and then do some action (forward new entry via WS).

First part of the use case reminds me some similar threads [1], [2], [3] from the Community archive. Summarizing those ones, you have basically two options:

  1. Make use of HANA Triggers [4] and react on new entries in the DB table.
  2. Configure IoT HTTP Message Processing (Message Forwarding) [5] in addition to the default SQL one, so that your device messages are also forwarded to some arbitrary HTTP endpoint (implemented by you).

As for the second part (forwarding an entry via WS):

  1. In case of HANA Triggers I am not quite sure if XS is able to establish WS connectivity (never tried it myself).
  2. In case of HTTP endpoint, you are free to implement WS connectivity yourself. It is completely on you what to do when you receive the forwarded message from IoT MMS.

Hope this helps.

Regards,

Anton

[1] https://archive.sap.com/discussions/thread/3891613

[2] https://archive.sap.com/discussions/thread/3828005

[3] https://archive.sap.com/discussions/thread/3897617

[4] https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.00/en-US/20d5a65575191014946db96aae...

[5] https://help.sap.com/viewer/7436c3125dd5491f939689f18954b1e9/Cloud/en-US/65055489297046f3808757aa7ee...

collinjona
Explorer
0 Kudos

Thanks Anton,

I will try and let you inform 🙂

Thanks for your help

lbreddemann
Active Contributor
0 Kudos

Hi Anton

I've seen your answer (to use HANA triggers) for this kind of requirement now a couple of time and always wonder how that would actually help to solve the issue.

Sure, when a new record gets inserted into a table, one can call some HANA procedure or change the data, but there is no option to signal the XS/XSA app connected to the HANA instance in this setup.

If I'm following correctly, the only way for the application to notice and react to new records in the table would be to poll the table and look for new entries. Is that correct? Or how else would that work?

Thanks for sharing your approach!

Lars

anton_levin
Advisor
Advisor

Hello Lars,

when suggesting Triggers those days, I have been pretty much confident that calling XSJS procedures by Triggers was a part of the hands-on session done by Thomas in one of those firsts openSAP "SAP HANA" courses [1] (late 2013). Now, after watching some of the videos, I couldn't find it. Also, this direct answer [2] from Thomas confirms that I was wrong. My fault.

So, the only way would be to poll the table, as you say. Thanks for correction!

[1] https://open.sap.com/courses/hana1-1

[2] https://archive.sap.com/discussions/thread/3767268

lbreddemann
Active Contributor
0 Kudos

Thanks for the super swift clarification. Much appreciated.