Outbox
The outbox is responsible for adding messages to the storage and then adding at least once to the transport.
builder.Services.AddTransactionalBox(x =>
{
x.AddOutbox(
storage => ...,
transport => ...,
settings => ...,
assembly => ...
);
},
settings => settings.ServiceId = "ServiceName");
Outbox Message
info
Outbox message class name must be unique per service.
public class CreateCustomerCommandMessage : OutboxMessage
{
public Guid Id { get; init; }
public string FirstName { get; init; }
public string LastName { get; init; }
public int Age { get; init; }
}
Outbox Definition
info
You do not need to define a outbox definition for each message.
By default, the message will be published because receiver is not indicated.
internal class CreateCustomerCommandMessageDefinition : OutboxDefinition<CreateCustomerCommandMessage>
{
public CreateCustomerCommandMessageDefinition()
{
Receiver = "Customers";
}
}
Adding a message to the outbox
// Add in the same transaction the result of the business operation and message to outbox
await outbox.Add(message);
// Commit transaction
// After transaction is successfully commited, execute the following method
await outbox.TransactionCommited();
Storage
Options |
In Memory (Default) |
Entity Framework Core (Relational) |
Transport
Options |
In Memory (Default) |
Apache Kafka |
Settings
AddMessagesToTransportSettings
Name | Type | Default Value | Description |
MaxBatchSize | int | 5000 | Maximum number of processing messages per job. |
LockTimeout | TimeSpan | 10 seconds | Time to live for message blocking. |
CleanUpOutboxSettings
Name | Type | Default Value | Description |
MaxBatchSize | int | 10000 | Maximum number of messages to clean up per job. |
IsEnabled | bool | true | Value responsible for whether the cleaning process is enabled. |
ConfigureSerialization
Name | Extension |
System.Text.Json (Default) | UseSystemTextJson() |
ConfigureCompression
Name | Extension |
No compression (Default) | UseNoCompression() |
Brotli | UseBrotli() |
GZip | UseGZip() |