Reputation: 64943
There's a message queue domain. This domain may work with some message queue technology. In this particular case it's bound to Windows Azure Service Bus.
Some project has an operation that registers a Windows Azure Service Bus topic (basically, a message queue).
Registering a new message queue means:
Above background it should work fine if domain transaction ends successfully and Windows Azure Service Bus topic registration worked fine.
But what happens if domain transaction ends successfully but Windows Azure Service Bus couldn't register the topic - aka message queue -?
Yes, you've a broken domain.
And what happens if you make the Windows Azure Service Bus topic registration before the domain transaction starts? Well, if everything goes fine, no problem. But now the problem has been inverted: what happens if Windows Azure Service Bus topic gets correctly registered but later the domain transaction fails?
Right, this second case is better than first described one, because the operation has registered an useless message queue but domain won't know about it . Mainly the problem now is that an indeterminate number of transactions may fail and an unknown number of message queues would be there just for nothing.
Just imagine if this is a serious and large business service: a lot of useless message queues and a system administrator (a human) deleting useless message queues every month.
Since I find the option of having useless message queues better than having a broken domain, I've opted-in on going forward on this way, but...has Windows Azure any kind of distributed transaction mechanism in order to include any remote object creation in an atomic transaction including other domain-specific operations?, If not - sadly I believe that this is the actual situation -, how would you solve this scenario?
I'm looking for something like this because I really don't like to have a domain that can't handle its use cases at all. I prefer to avoid this and let domain work properly and have everything in control.
I've found some interesting link about this topic:
Upvotes: 3
Views: 1490
Reputation: 24895
You can solve this without transactions by using states. Imagine the following workflow:
Then you can have a small process that checks the pending domains:
With a retry policy in place (like TOPAZ), you won't have any issues in 99% of the requests. But whenever something goes wrong, it will get fixed automatically or it will escalate to a human intervention if it can't be fixed.
The alternative would be something like in Clemens' blog post, where you use an outbox table in SQL Azure and you write to this outbox table in the same transaction where you register the domain.
Upvotes: 6