Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompensateAsync not fired in When using saga inside Azure Service Bus handler #60

Open
abuzaforfagun opened this issue Mar 15, 2021 · 0 comments

Comments

@abuzaforfagun
Copy link

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.

abuzaforfagun added a commit to abuzaforfagun/Chronicle that referenced this issue Mar 15, 2021
abuzaforfagun added a commit to abuzaforfagun/Chronicle that referenced this issue Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant