title | component | versions | related | reviewed | |
---|---|---|---|---|---|
Transactions in Azure Table persistence |
ASP |
ASTP:[3,] |
|
2024-02-09 |
partial: intro
A custom behavior must be introduced to identify and insert the TableEntityPartitionKey
value into the pipeline context for use by storage operations that occur during the processing of a given message.
Note
Do not use a message mutator to identify the partition key. Message mutators do not offer the necessary control or timing to reliably interact with this persistence.
The custom behavior can be introduced in one of the two stages:
This is the earliest stage in the message processing pipeline. At this stage only the message ID, the headers and a byte array representation of the message body are available.
snippet: ITransportReceiveContextBehavior
This stage occurs before the outbox logic is executed. Identifying the TableEntityPartitionKey
during this stage allows the outbox feature to work entirely as intended. In the case where the TableEntityPartitionKey
cannot be identified using only the message headers, a behavior in the IIncomingLogicalMessageContext
stage can be introduced instead.
This is the first stage in the pipeline that allows access to the deserialized message body. At this stage both the message headers and deserialized message object are available.
snippet: IIncomingLogicalMessageContextBehavior
Outbox message guarantees work by bypassing the remaining message processing pipeline when an outbox record is located. Since this stage occurs after the normal bypass logic is executed, no TableEntityPartitionKey
is available to locate an existing outbox record.
Azure Table persistence introduces a new LogicalOutboxBehavior
to locate the outbox record and bypass the remaining message processing pipeline in the same IIncomingLogicalMessageContext
stage as the custom TableEntityPartitionKey
behavior. As a result, the custom behavior must be inserted into the pipeline before the LogicalOutboxBehavior
.
To specify the ordering for the custom TableEntityPartitionKey
behavior:
snippet: InsertBeforeLogicalOutbox
To register the custom TableEntityPartitionKey
behavior:
snippet: RegisterLogicalBehavior
Warning
Caution must be used when custom behaviors have been introduced in the pipeline that dispatch messages immediately. If these behaviors execute before the LogicalOutboxBehavior
the outbox message guarantees may be broken.
partial: sharing