Monitor Messages
When you may need message monitor?
The Message Monitor object is based on the GraphQL API extension of the same name. It was developed to solve the problem of batch external message processing.
About Message Monitor
Message Monitor
caches the transactions of the last block to provide all users with shard block walking on the backend side, giving batch results, and removing the need to send multiple queries for every message in a batch to discover their status.
Also it ensures a transaction error trace is received on the backend if the transaction was not executed onchain within the specified timeout.
Message Monitor
allows to:
subscribe for the statuses of a batch of messages via websocket
query the status of a batch of messages with 1 query
monitor object in SDK provides additional capabilities that allow to process messages using a special queue.
Message Monitor Specifications are available here: Message Monitor.
Usage
Let’s look at the following Javascript SDK sample, that offers two use cases:
I want to send 100 messages at 10 messages per second and get their processing status AS SOON as possible.
I want to send 100 messages at 10 messages per second and only get their status when ALL messages have been processed.
The relevant part of the first use case is below:
Here wait_mode
is set to MonitorFetchWaitMode.AtLeastOne
, making sure Monitor will deliver message processing results as they come in.
Compare to the second use case, where wait_mode
is set to MonitorFetchWaitMode.All
, making monitor wait for all results of the queue to be received:
Sample source code
Javascript:
https://github.com/everx-labs/sdk-samples/tree/master/core-examples/node-js/message-monitor
Rust:
https://github.com/everx-labs/sdk-samples/tree/master/core-examples/rust/message-monitoring
Last updated