My team has a windows service which host a wcf service using http binding. When the wcf service receives a message, it immediately sends it to another wcf service, using NetMsmqBinding, also hosted in a windows service. The msmq service process the message and save it do our DB.
In the development and staging environments, everything worked fine. When we deployed to production though, we saw that messages sent to our service are being multiplied by a factor of n+1 (for n messages).
For example: 1 message received, 2 saved to DB. 4 messages received, 20 saved to DB etc.
We suspect that it has something to do with the msmq service settings of Transactions,
Concurrency, and InstanceContextMode, but we can't figure it out.
The settings of the service are:
We use .Net 4, MSMQ 3.0 and Windows server 2003.
Any ideas to what might cause this issue?
Edit:
After a lot of research, we have discovered the following things:
We really are clueless...
Thanks
Well, we finally got it: we use Entlib for logging, and we added a DB listener. Entlib DB listener uses the same transaction of the service. When it tries to pass the transaction to the DB server, an error is thrown because MSDTC wasn't configured correctly on the DB server, which causes the transaction to rollback. When the WCF runtime tries to commit the transaction, it fails because it was already aborted, and then it tries to process the same message again (because of the built-in retry mechanism).
When we fixed the MSDTC settings, the duplication stopped.
Now, all we need to figure out is: why rollback to the service transaction causes messages to be multiplied so many times?