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

Messages not getting sent when SqlConnection is used inside message handlers #26

Closed
peuramaki opened this issue Mar 27, 2014 · 1 comment
Milestone

Comments

@peuramaki
Copy link
Contributor

It appears that when custom SQL queries to MS SQL Server (using SqlConnection) are made during the lifetime of a NServiceBus message handler, non-deterministic behavior is resulted. Sometimes ambient transaction is never committed, which results in NServiceBus.RabbitMQ never sending out messages that should be sent. That is apparently because flushing of NSB's unit of work is bound to TransactionCompleted event, which sometimes never launches.

I'm able to work around the issue the following way: instead of letting SqlConnection to automatically enlist to ambient transaction, I'm preventing it using 'Enlist=false' in connection string. I don't use System.Transactions at all with the SqlConnection, but I hook up SqlTransaction using NServiceBus'es IManageUnitsOfWork interface.

The issue can be reproduced: https://github.com/peuramaki/NServiceBus.RabbitMq.Issue26

EDIT: workaround suggested here doesn't fix my production scenario, non-deterministic behavior continues.

It also seems that if I forget to close the SqlConnection (or return it to connection pool), non-deterministic behavior is gone.

@peuramaki
Copy link
Contributor Author

Issue fixed in pull request #27

@johnsimons johnsimons added this to the 1.1.1 milestone Apr 2, 2014
@johnsimons johnsimons added the bug label Apr 2, 2014
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

2 participants