I have tried to use Chronicle ProcessAsync from Azure Service Bus message handler, like below:
`
public void RegisterQueueHandler(string primaryKey, string queueName) where T : class
{
var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandler)
{
MaxConcurrentCalls = 1,
AutoComplete = false
};
_queueClient = new QueueClient(primaryKey, queueName);
_queueClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
}
private async Task ProcessMessagesAsync<T>(Message message, CancellationToken token) where T : class
{
using var serviceProviderScope = _serviceProvider.CreateScope();
var payload = JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(message.Body));
if (payload is ISagaCommand)
{
var sagaCoordinator = serviceProviderScope.ServiceProvider.GetRequiredService<ISagaCoordinator>();
await sagaCoordinator.ProcessAsync(payload, null);
}
else
{
var mediator = serviceProviderScope.ServiceProvider.GetRequiredService<IMediator>();
await mediator.Send(payload, token);
}
await _queueClient.CompleteAsync(message.SystemProperties.LockToken);
}
`
When any exception happens inside saga HandleAsync, CompensateAsync is ignored and ExceptionReceivedHandler fired.
I have tried to use Chronicle ProcessAsync from Azure Service Bus message handler, like below: ` public void RegisterQueueHandler(string primaryKey, string queueName) where T : class
{
var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandler)
{
MaxConcurrentCalls = 1,
AutoComplete = false
};
_queueClient = new QueueClient(primaryKey, queueName);
_queueClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
}
`
When any exception happens inside saga
HandleAsync
,CompensateAsync
is ignored andExceptionReceivedHandler
fired.