JDP Science Tools

cancel
Showing results for 
Search instead for 
Did you mean: 

gRPC to Messenger Library Demonstration

As the NI gRPC Library is published, I thought I would post some prototyping work I did in interfacing Messenger Library with a gRPC Server.  Here is a GIF where I connect to the Server using BloomRPC

gRPC ML.gif

Message 1 of 9
(343 Views)

The actual code need in use is just one dropin subVI to create the Server (otherwise, there is no changes needed as teh gRPC Server just interfaces with the existing Messenger-Library Request-Reply and Register-Notify systems):

drjdpowell_0-1729069100627.png

 

Message 2 of 9
(326 Views)

Here is the gRPC Proto file:

 

// Service exposing Notifications from a Messenger Library Notification Server
// https://www.vipm.io/package/ni_lib_labview_grpc_library/
// https://www.vipm.io/package/drjdpowell_lib_messenging/
// Also uses JSONtext: https://www.vipm.io/package/jdp_science_jsontext/
// James Powell, 2022

syntax = "proto3";

package MessengerLibrary;

// Interface exported by the server.
service Notification {
  // Register to get standard Messenger Library Notifications
  rpc RegisterByLabels_JSON(RegistrationByLabels) returns (stream Notification_String) {}
  rpc RegisterByLabel_JSON(RegistrationByLabel) returns (stream Notification_String) {}
  rpc RegisterByLabel_DBL(RegistrationByLabel) returns (stream Notification_DBL) {}
  // Messenger Library Request-Reply
  rpc RequestReply_DBL(RequestReply_DBL) returns (Notification_DBL) {}
}

// Registration messages
message RegistrationByLabels {
  repeated string Labels = 1;
  string Prefix = 2; // Optional Prefix to add to Label
}
message RegistrationByLabel {
  string Label = 1;
  string Relabel = 2; // Optional different label coming back
}

// Notification messages
message Notification_String {
  string Label = 1;
  string Value_String = 2;
}
message Notification_DBL {
  string Label = 1;
  double Value_DBL = 2;
}

// Requests (aka Commands)
message RequestReply_DBL {
  string Label = 1;
  string ReplyLabel = 2; // Optional different label coming back
  double RequestData = 3; // Optional Data
}

Message 3 of 9
(316 Views)

Hi James,

 

you might have seem my message on VIPM. I would be interested in a TCP JSON implementation of Messenger and more imperatively a network streams version

0 Kudos
Message 4 of 9
(207 Views)

Why do you want a Network Streams version?  I ask because Network Streams is on top of TCP, so I don't understand what extra value it would bring.

0 Kudos
Message 5 of 9
(196 Views)

I'm transmitting over a flaky connection and seem to have a lot of packet drop. From my reading Network streams are lossless so should fix my issue superficially

0 Kudos
Message 6 of 9
(85 Views)

TCP is lossless (asks for retransmit of lost packets).  

0 Kudos
Message 7 of 9
(82 Views)

Then I should setup my hardware again and try to find the root cause

0 Kudos
Message 8 of 9
(68 Views)

WRT the json serialised message format. I have interests in cross language communications. Only briefly refreshing my understanding of the TCP actors, it appears it would be a decent chunk of work to change the message serialisation from flatten to string to a JSON or XML format

0 Kudos
Message 9 of 9
(65 Views)