HomePhabricator
Diffusion Comm 6bcde7aebe0d

[services] Tunnelbroker - Adding delivering messages from the deliveryBroker to…

Description

[services] Tunnelbroker - Adding delivering messages from the deliveryBroker to the messages stream

Summary:
This diff adds immediate delivery of messages when the client is online and connected to the bidirectional stream. We are using the AMQP server to immediately send/receive messages.

When the client sends a message to another client through the Tunnelbroker, the message is stored in the database and the AMQP message is put into the AMQP server queue to which the Tunnelbroker (or another Tunnelbroker instance) is listen for new messages to come. After the new message is came from the AMQP server we will send it to the client as the MessagesToDeliver by the gRPC stream message.

The client will process the message and send back the processed message ID to the Tunnelbroker as processedMessages only after that, we will delete messages from the database.

Removing of processed messages implemented in D5584.

Linear task: ENG-2060

Test Plan:

  1. Connect by the gRPC client to the bidirectional stream with the sessionID corresponding to the deviceID in metadata.
  2. Insert a message in the database into the messages table with the corresponding deviceID in the toDeviceID field.
  3. Put a message into the AMQP queue with the corresponding deviceID in the toDeviceID field in the message amqp header.

The expected result is that the message would be delivered to the client as the MessagesToDeliver.

Reviewers: jon, varun, marcin, tomek

Reviewed By: jon, tomek

Subscribers: ashoat, tomek, atul, abosh

Differential Revision: https://phab.comm.dev/D5580