java.lang.Object
tech.deplant.java4ever.binding.Processing
Processing
Contains methods of "processing" module of EVER-SDK API
Message processing module. This module incorporates functions related to complex message processing scenarios.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
static final record
static final record
static enum
static final record
static final record
static final record
static interface
static enum
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static final record
static enum
static interface
static final record
static final record
static final record
static final record
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
cancelMonitor
(int ctxId, String queue) Cancels all background activity and releases all allocated system resources for the specified monitoring queue.fetchNextMonitorResults
(int ctxId, String queue, Processing.MonitorFetchWaitMode waitMode) Results and waiting options are depends on the `wait` parameter.getMonitorInfo
(int ctxId, String queue) Returns summary information about current state of the specified monitoring queue.static void
monitorMessages
(int ctxId, String queue, Processing.MessageMonitoringParams[] messages) Message monitor performs background monitoring for a message processing results for the specified set of messages.processMessage
(int ctxId, Abi.ABI abi, String address, Abi.DeploySet deploySet, Abi.CallSet callSet, Abi.Signer signer, Integer processingTryIndex, Long signatureId, Boolean sendEvents) Creates ABI-compatible message, sends it to the network and monitors for the result transaction.sendMessage
(int ctxId, String message, Abi.ABI abi, Boolean sendEvents, Consumer<com.fasterxml.jackson.databind.JsonNode> callback) Sends message to the network and returns the last generated shard block of the destination account before the message was sent.sendMessages
(int ctxId, Processing.MessageSendingParams[] messages, String monitorQueue) Sends specified messages to the blockchain.waitForTransaction
(int ctxId, Abi.ABI abi, String message, String shardBlockId, Boolean sendEvents, String[] sendingEndpoints, Consumer<com.fasterxml.jackson.databind.JsonNode> callback) `send_events` enables intermediate events, such as `WillFetchNextBlock`, `FetchNextBlockFailed` that may be useful for logging of new shard blocks creation during message processing.
-
Constructor Details
-
Processing
public Processing()
-
-
Method Details
-
monitorMessages
public static void monitorMessages(int ctxId, String queue, Processing.MessageMonitoringParams[] messages) throws EverSdkException Message monitor performs background monitoring for a message processing results for the specified set of messages. Message monitor can serve several isolated monitoring queues. Each monitor queue has a unique application defined identifier (or name) used to separate several queue's. There are two important lists inside of the monitoring queue: - unresolved messages: contains messages requested by the application for monitoring and not yet resolved; - resolved results: contains resolved processing results for monitored messages. Each monitoring queue tracks own unresolved and resolved lists. Application can add more messages to the monitoring queue at any time. Message monitor accumulates resolved results. Application should fetch this results with `fetchNextMonitorResults` function. When both unresolved and resolved lists becomes empty, monitor stops any background activity and frees all allocated internal memory. If monitoring queue with specified name already exists then messages will be added to the unresolved list. If monitoring queue with specified name does not exist then monitoring queue will be created with specified unresolved messages. Starts monitoring for the processing results of the specified messages.- Parameters:
queue
- Name of the monitoring queue.messages
- Messages to start monitoring for.- Throws:
EverSdkException
-
getMonitorInfo
public static CompletableFuture<Processing.MonitoringQueueInfo> getMonitorInfo(int ctxId, String queue) throws EverSdkException Returns summary information about current state of the specified monitoring queue.- Parameters:
queue
- Name of the monitoring queue.- Throws:
EverSdkException
-
fetchNextMonitorResults
public static CompletableFuture<Processing.ResultOfFetchNextMonitorResults> fetchNextMonitorResults(int ctxId, String queue, Processing.MonitorFetchWaitMode waitMode) throws EverSdkException Results and waiting options are depends on the `wait` parameter. All returned results will be removed from the queue's resolved list. Fetches next resolved results from the specified monitoring queue.- Parameters:
queue
- Name of the monitoring queue.waitMode
- Default is `NO_WAIT`. Wait mode.- Throws:
EverSdkException
-
cancelMonitor
Cancels all background activity and releases all allocated system resources for the specified monitoring queue.- Parameters:
queue
- Name of the monitoring queue.- Throws:
EverSdkException
-
sendMessages
public static CompletableFuture<Processing.ResultOfSendMessages> sendMessages(int ctxId, Processing.MessageSendingParams[] messages, String monitorQueue) throws EverSdkException Sends specified messages to the blockchain.- Parameters:
messages
- Messages that must be sent to the blockchain.monitorQueue
- Optional message monitor queue that starts monitoring for the processing results for sent messages.- Throws:
EverSdkException
-
sendMessage
public static CompletableFuture<Processing.ResultOfSendMessage> sendMessage(int ctxId, String message, Abi.ABI abi, Boolean sendEvents, Consumer<com.fasterxml.jackson.databind.JsonNode> callback) throws EverSdkException Sends message to the network and returns the last generated shard block of the destination account before the message was sent. It will be required later for message processing. Sends message to the network- Parameters:
message
- Message BOC.abi
- If this parameter is specified and the message has the `expire` header then expiration time will be checked against the current time to prevent unnecessary sending of already expired message. The `message already expired` error will be returned in this case. Note, that specifying `abi` for ABI compliant contracts is strongly recommended, so that proper processing strategy can be chosen. Optional message ABI.sendEvents
- Flag for requesting events sending. Default is `false`.- Throws:
EverSdkException
-
waitForTransaction
public static CompletableFuture<Processing.ResultOfProcessMessage> waitForTransaction(int ctxId, Abi.ABI abi, String message, String shardBlockId, Boolean sendEvents, String[] sendingEndpoints, Consumer<com.fasterxml.jackson.databind.JsonNode> callback) throws EverSdkException `send_events` enables intermediate events, such as `WillFetchNextBlock`, `FetchNextBlockFailed` that may be useful for logging of new shard blocks creation during message processing. Note, that presence of the `abi` parameter is critical for ABI compliant contracts. Message processing uses drastically different strategy for processing message for contracts which ABI includes "expire" header. When the ABI header `expire` is present, the processing uses `message expiration` strategy: - The maximum block gen time is set to `message_expiration_timeout + transaction_wait_timeout`. - When maximum block gen time is reached, the processing will be finished with `MessageExpired` error. When the ABI header `expire` isn't present or `abi` parameter isn't specified, the processing uses `transaction waiting` strategy: - The maximum block gen time is set to `now() + transaction_wait_timeout`. - If maximum block gen time is reached and no result transaction is found, the processing will exit with an error. Performs monitoring of the network for the result transaction of the external inbound message processing.- Parameters:
abi
- If it is specified, then the output messages' bodies will be decoded according to this ABI. The `abi_decoded` result field will be filled out. Optional ABI for decoding the transaction result.message
- Encoded with `base64`. Message BOC.shardBlockId
- You must provide the same value as the `send_message` has returned. The last generated block id of the destination account shard before the message was sent.sendEvents
- Flag that enables/disables intermediate events. Default is `false`.sendingEndpoints
- Use this field to get more informative errors. Provide the same value as the `send_message` has returned. If the message was not delivered (expired), SDK will log the endpoint URLs, used for its sending. The list of endpoints to which the message was sent.- Throws:
EverSdkException
-
processMessage
public static CompletableFuture<Processing.ResultOfProcessMessage> processMessage(int ctxId, Abi.ABI abi, String address, Abi.DeploySet deploySet, Abi.CallSet callSet, Abi.Signer signer, Integer processingTryIndex, Long signatureId, Boolean sendEvents) throws EverSdkException Creates ABI-compatible message, sends it to the network and monitors for the result transaction. Decodes the output messages' bodies. If contract's ABI includes "expire" header, then SDK implements retries in case of unsuccessful message delivery within the expiration timeout: SDK recreates the message, sends it and processes it again. The intermediate events, such as `WillFetchFirstBlock`, `WillSend`, `DidSend`, `WillFetchNextBlock`, etc - are switched on/off by `send_events` flag and logged into the supplied callback function. The retry configuration parameters are defined in the client's `NetworkConfig` and `AbiConfig`. If contract's ABI does not include "expire" header then, if no transaction is found within the network timeout (see config parameter ), exits with error. Creates message, sends it to the network and monitors its processing.- Parameters:
abi
- Contract ABI.address
- Must be specified in case of non-deploy message. Target address the message will be sent to.deploySet
- Must be specified in case of deploy message. Deploy parameters.callSet
- Must be specified in case of non-deploy message. In case of deploy message it is optional and contains parameters of the functions that will to be called upon deploy transaction. Function call parameters.signer
- Signing parameters.processingTryIndex
- Used in message processing with retries (if contract's ABI includes "expire" header). Encoder uses the provided try index to calculate message expiration time. The 1st message expiration time is specified in Client config. Expiration timeouts will grow with every retry. Retry grow factor is set in Client config: <.....add config parameter with default value here> Default value is 0. Processing try index.signatureId
- Signature ID to be used in data to sign preparing when CapSignatureWithId capability is enabledsendEvents
- Flag for requesting events sending. Default is `false`.- Throws:
EverSdkException
-