A queue with session enabled will guarantee the message stay in the order.
Azure Service Bus with session enabled automatically group messages into sessions.
Transaction in Service Bus:
Using a transaction group combines two or more operations together in execution scope. It is processed as a single unit. In transaction retry does not happen when any exception.
- Send
- Complete
- Abandon
- Deadletter
- Defer
- Renew lock
var options = new ServiceBusClientOptions { EnableCrossEntityTransactions = true };
await using var client = new ServiceBusClient(connectionString, options);
ServiceBusReceiver receiverA = client.CreateReceiver("queueA");
ServiceBusSender senderB = client.CreateSender("queueB");
ServiceBusReceivedMessage receivedMessage = await receiverA.ReceiveMessageAsync();
using (var ts = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await receiverA.CompleteMessageAsync(receivedMessage);
await senderB.SendMessageAsync(new ServiceBusMessage());
ts.Complete();
}
Message Session in Service Bus:
It allow joint and ordered procession of unbound sequence of related messages.
Session can be used FIFO and request-response pattern.
Sender can initiate a seesion when submitting message into topi with session-ID property. At AMQP 1.o it will be mapped to group-id property
Duplicate Detection in Service Bus:
When creating queue enable duplicate detection and set the detction window.
Partitioning in Service Bus:
A queue or topic is handled by a single message broker and stored in one messaging store.
A Service Bus enable queues and topics to be partitioned across multiple message brokers and message stores.
Topic Filters and Action in Service Bus:
## Filters
It's a rule consists of filter condition that selects particular message (e.g., SQL Filter, Boolean Filter, Correlation Filter)
## Action
It's a update statement. The action is done on the message after it has been matched and before message is selected into subscription.
adminClient = new ServiceBusAdministrationClient(connectionString);
// Create a SQL filter with color set to red
// Action is defined to set the quantity to half if the color is red
await adminClient.CreateRuleAsync(topicName, "ColorRed", new CreateRuleOptions
{
Name = "RedOrdersWithAction",
Filter = new SqlRuleFilter("user.color='red'"),
Action = new SqlRuleAction("SET quantity = quantity / 2;")
}
Transaction in Service Bus:
Transaction in Service Bus:
Patterns in Service Bus:
- Broadcast Pattern
- Partition Pattern
- Routing Pattern
Top comments (0)