I’m interested to know what the transactional behavior is in this scenario. We have a need to integrate to an external client system via Http Post. This external Api however can take a very long time to process and the .NET client can timeout, but the api call may still be successful. In such a scenario, we cannot deterministically tell if the call was successful (sometimes it is). In the case a retry was kicked off, we want to send an email communication to the client stating that there may be a possible duplicate entry in their system.
I am interested in knowing what happens when we have an endpoint configured as such:
class ConfigureTransactions : INeedInitialization
{
public void Customize(BusConfiguration configuration)
{
configuration.Transactions()
.DisableDistributedTransactions()
.DoNotWrapHandlersExecutionInATransactionScope();
}
}
and a handler that does the following:
public void Handle(SendToExternalSystem message)
{
if (IsRetry()) // check headers
{
DispatchRetryEmail(message);
}
externalSystem.Post(xml); //http post
}
private void DispatchRetryEmail(SendToExternalSystem email)
{
using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
var sendEmail = new SendEmail
{
Email = new Email () { } // email details }
};
bus.Send(sendEmail);
scope.Complete();
}
}
I understand that this does not completely make sense. In one part, we’re disabling DTC and transaction scope, yet we’re creating a new transaction scope. Without getting into the business details, a bug was introduced because the ConfigureTransactions class included in a changeset, which prevented the emails from being sent.
I would like to know the mechanics of why the emails were not sent and how disabling transactions at an endpoint level and creation of transactionscope within a handler interact.
Thanks in advance!