Send GRPC message
Sends the next message to the client or bidirectional stream
- Parameters
- Advanced call ?
Function SendGRPCMessage(Val Connection, Val StreamID, Val Request, Val Session = Undefined, Val WaitNext = False) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | - | Arbitrary | ✔ | GRPC connection object |
| StreamID | - | String | ✔ | Stream Identifier |
| Request | - | Structure Of KeyAndValue | ✔ | Request data. See GetRequestSettings |
| Session | - | Structure Of KeyAndValue | ✖ | Session settings. See GetSessionSettings |
| WaitNext | - | Boolean | ✖ | Flag for waiting for the next messages after the current one |
Returns
Map Of KeyAndValue - Processing result
This method has no additional advanced call parameters.
Caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
URL = "http://localhost:9101";
Login = "bayselonarrend";
Password = "12we...";
Authorization = New Structure(Login, Password);
ConnectionSettings = OPI_ClickHouse.GetGRPCConnectionSettings(URL, Authorization);
Connection = OPI_ClickHouse.CreateGRPCConnection(ConnectionSettings);
Result = OPI_ClickHouse.OpenGRPCStream(Connection);
If Not Result["result"] Then
Raise Result["error"];
Else
StreamID = Result["streamId"];
EndIf;
QueryText = "INSERT INTO events_stream_test FORMAT JSONEachRow";
DataFormat = "JSON";
CurrentDate = Date("20260101100000");
Counter = 0;
While Counter < 5 Do
Record = New Structure;
Record.Insert("id" , Counter + 1);
Record.Insert("timestamp" , CurrentDate);
Record.Insert("user_id" , 100 + Counter);
Record.Insert("event_type" , "stream_test");
Record.Insert("payload" , "{}");
Record = OPI_Tools.JSONString(Record) + Chars.LF;
Last = Counter = 4;
If Counter = 0 Then
Request = OPI_ClickHouse.GetRequestSettings(QueryText, "default", , Record, DataFormat);
CurrentSend = OPI_ClickHouse.SendGRPCMessage(Connection, StreamID, Request, , Not Last); // <---
Else
CurrentSend = OPI_ClickHouse.SendGRPCData(Connection, StreamID, Record, Not Last);
EndIf;
If Not CurrentSend["result"] Then
Error = CurrentSend["error"];
If Error <> "Timeout" Then
Raise OPI_Tools.JSONString(CurrentSend);
EndIf;
EndIf;
Counter = Counter + 1;
EndDo;
Result
{
"result": true,
"streamId": "333ae7ad-ad77-4908-8e86-e81ae8a4c187"
}