Inbox
The inbox is responsible for getting messages from the transport and adding them to the storage, and then processes these messages.
tip
You can run inbox as a standalone service. You add reference to shared assemblies, but deploy as separate services. This way, processing in inbox does not affect the performance of your service.
builder.Services.AddTransactionalBox(x =>
{
x.AddInbox(
storage => ...,
transport => ...,
settings => ...,
assembly => ...
);
},
settings => settings.ServiceId = "ServiceName");
Inbox Message
info
Inbox message class name must be unique per service.
public class CreateCustomerCommandMessage : InboxMessage
{
public Guid Id { get; init; }
public string FirstName { get; init; }
public string LastName { get; init; }
public int Age { get; init; }
}
Inbox Definition
info
You do not need to define a inbox definition for each message.
Listens by default for incoming messages to the current service (does not listen on events).
If you want to listen for events, you need to define the PublishedBy
property.
public class CreatedCustomerEventMessageDefinition : InboxDefinition<CreatedCustomerEventMessage>
{
public CreatedCustomerEventMessageDefinition()
{
PublishedBy = "Customers";
}
}
Handling message in inbox handler
info
Each InboxMessage
must have a IInboxHandler
declared.
public class CreatedCustomerEventMessageHandler : IInboxHandler<CreatedCustomerEventMessage>
{
...
public async Task Handle(CreatedCustomerEventMessage message, IExecutionContext executionContext)
{
// Your logic
}
}
Storage
Options |
In Memory (Default) |
Entity Framework Core (Relational) |
Transport
Options |
In Memory (Default) |
Apache Kafka |
Settings
AddMessagesToInboxSettings
Name | Type | Default Value | Description |
DefaultTimeToLiveIdempotencyKey | TimeSpan | 7 days | Default time to live idempotency key. After the time expires, the key will be removed. |
CleanUpInboxSettings
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. |
CleanUpIdempotencyKeysSettings
Name | Type | Default Value | Description |
MaxBatchSize | int | 10000 | Maximum number of idepotency keys to clean up per job. |
Period | TimeSpan | 1 hour | Time interval between cleaning idepotency keys. |
ConfigureDeserialization
Name | Extension |
System.Text.Json (Default) | UseSystemTextJson() |