{"action":"created","issue":{"url":"https://api.github.com/repos/Particular/NServiceBus/issues/2886","labels_url":"https://api.github.com/repos/Particular/NServiceBus/issues/2886/labels{/name}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/issues/2886/comments","events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/2886/events","html_url":"https://github.com/Particular/NServiceBus/issues/2886","id":106013616,"number":2886,"title":"Remove support for transactional MSMQ combined with TimeToBeReceived(TTBR)","user":{"login":"janovesk","id":396480,"avatar_url":"https://avatars.githubusercontent.com/u/396480?v=3","gravatar_id":"","url":"https://api.github.com/users/janovesk","html_url":"https://github.com/janovesk","followers_url":"https://api.github.com/users/janovesk/followers","following_url":"https://api.github.com/users/janovesk/following{/other_user}","gists_url":"https://api.github.com/users/janovesk/gists{/gist_id}","starred_url":"https://api.github.com/users/janovesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janovesk/subscriptions","organizations_url":"https://api.github.com/users/janovesk/orgs","repos_url":"https://api.github.com/users/janovesk/repos","events_url":"https://api.github.com/users/janovesk/events{/privacy}","received_events_url":"https://api.github.com/users/janovesk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Particular/NServiceBus/labels/Impact:%20M","name":"Impact: M","color":"e11d21"},{"url":"https://api.github.com/repos/Particular/NServiceBus/labels/Size:%20S","name":"Size: S","color":"B6FF00"},{"url":"https://api.github.com/repos/Particular/NServiceBus/labels/State:%20In%20Progress","name":"State: In Progress","color":"ededed"},{"url":"https://api.github.com/repos/Particular/NServiceBus/labels/Type:%20Bug","name":"Type: Bug","color":"e10c02"}],"state":"open","locked":false,"assignee":{"login":"janovesk","id":396480,"avatar_url":"https://avatars.githubusercontent.com/u/396480?v=3","gravatar_id":"","url":"https://api.github.com/users/janovesk","html_url":"https://github.com/janovesk","followers_url":"https://api.github.com/users/janovesk/followers","following_url":"https://api.github.com/users/janovesk/following{/other_user}","gists_url":"https://api.github.com/users/janovesk/gists{/gist_id}","starred_url":"https://api.github.com/users/janovesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janovesk/subscriptions","organizations_url":"https://api.github.com/users/janovesk/orgs","repos_url":"https://api.github.com/users/janovesk/repos","events_url":"https://api.github.com/users/janovesk/events{/privacy}","received_events_url":"https://api.github.com/users/janovesk/received_events","type":"User","site_admin":false},"milestone":null,"comments":32,"created_at":"2015-09-11T13:42:33Z","updated_at":"2015-11-18T13:52:36Z","closed_at":null,"body":"Taskforce: @janovesk @szymonpobiega\r\n\r\n## Who's affected\r\nThis bug affects you if you have a transactional endpoint that uses the MSMQ transport and have any messages types with a non-default [TimeToBeReceived](http://docs.particular.net/nservicebus/messaging/discard-old-messages). \r\n\r\n## Symptoms\r\nMessage sent in a transaction do not get the configured TimeToBeReceived(TTBR). They are assigned a seemingly random TTBR if any. All the messages in a transaction gets the same TTBR, even though they are configured to have different TTBRs.\r\n\r\n### Background\r\n\r\nUsers can set a TimeToBeReceived for any messages type. The TimeToBeReceived indicates a period of time where this message needs to be kept alive. Afterwards, it can be removed. This can be valuable when you have a high volume of messages combined with low business value in delayed processing. Messages with TimeToBeReceived is treated like any other messages sent. The TTBR is simply passed on to the underlying transport, which is responsible for implementing the timeout.\r\n\r\n### Root cause\r\n\r\nUnfortunately, MSMQ does not support having differing TTBR when you send multiple messages in the same transaction. All the messages in the transaction get the TTBR of the first message sent. This is clearly not what end users wanted, having defined different TTBR for different message types. The failure is silent with no warnings given to the user.\r\n\r\nThe following statement from [MSDN](https://msdn.microsoft.com/en-us/library/system.messaging.message.timetobereceived(v=vs.110).aspx) confirms the underlying issue with MSMQ, TTBR and transactions:\r\n\r\n```When several messages are sent in a single transaction, Message Queuing uses the TimeToBeReceived property of the first message.```\r\n\r\n### Affected versions\r\nVersion 4 and 5 of NServiceBus\r\n\r\n### Plan of attack \r\n\r\n - [x] Modify V4 core to throw on send operations with the combination of MSMQ with transactions and message type with TTBR defined. [PR 4.7.9](https://github.com/Particular/NServiceBus/pull/3037)\r\n - [x] Modify V5core to throw on send operations with the combination of MSMQ with transactions and message type with TTBR defined. [PR 5.0.8](https://github.com/Particular/NServiceBus/pull/3038) [PR 5.1.6](https://github.com/Particular/NServiceBus/pull/3040) [PR 5.2.6](https://github.com/Particular/NServiceBus/pull/3042)\r\n - [ ] Modify V6 core to throw on send operations with the combination of MSMQ with transactions and message type with TTBR defined.\r\n - [ ] [Docu](http://docs.particular.net/nservicebus/operations/auditing)\r\n - [ ] Release & Announcement\r\n\r\n### Impact assessment\r\n\r\nCustomer must be using both MSMQ, run with transactions and have message types with TTBR set. Running transactional MSMQ is very common; the latter presumed to be less so. We do have confirmed customer reports on this, but I suspect this is also happening to customers without them knowing. It can be hard to notice that messages are removed prematurely or late from queues. Given the lack of complaints, this actual number of affected customers can't be very high. That said, when it occurs, it is effectively message loss. Therefore, I say **impact medium**. Size is only a couple edits to put an exception in place. It should be fairly quick, I'd say **size small**.\r\n\r\n## Customer communication\r\n\r\nWe have discovered a bug in the [TimeToBeReceived](http://docs.particular.net/nservicebus/messaging/discard-old-messages) feature. It lets you specify a TimeToBeReceived for your messages. If you use this in combination with the MSMQ transport and have transactions turned on, your messages might get the incorrect TimeToBeReceived set. The messages might get removed from the receiving queue prematurely or build up over time. \r\n\r\nUnfortunately, we have no other choice than to disable this piece of functionality when running the MSMQ transport because of underlying issues in MSMQ. If we detect that your have an endpoint with MSMQ, transactions and TTBR set on any message we will throw an exception at runtime to remove any possibility of message loss.\r\n\r\nThis means you have to either \r\n\r\n* Stop using TimeToBeReceived on your messages. Make sure that none of the message types scanned by NServiceBus has a [TimeToBeReceived attribute](http://docs.particular.net/nservicebus/messaging/discard-old-messages#using-an-attribute) on them and there are no [TTBR conventions](http://docs.particular.net/nservicebus/messaging/discard-old-messages#using-your-own-convention) defined.\r\n\r\n* Switch to either [non-transactional](http://docs.particular.net/nservicebus/messaging/transactions#transactions-unreliable) or [outbox]\r\n(http://docs.particular.net/nservicebus/messaging/transactions#outbox) -based endpoint. Such a choice **must not be taken lightly** as it potentially changes the delivery guarantees of your endpoint by turning off transactions against MSMQ."},"comment":{"url":"https://api.github.com/repos/Particular/NServiceBus/issues/comments/157719033","html_url":"https://github.com/Particular/NServiceBus/issues/2886#issuecomment-157719033","issue_url":"https://api.github.com/repos/Particular/NServiceBus/issues/2886","id":157719033,"user":{"login":"janovesk","id":396480,"avatar_url":"https://avatars.githubusercontent.com/u/396480?v=3","gravatar_id":"","url":"https://api.github.com/users/janovesk","html_url":"https://github.com/janovesk","followers_url":"https://api.github.com/users/janovesk/followers","following_url":"https://api.github.com/users/janovesk/following{/other_user}","gists_url":"https://api.github.com/users/janovesk/gists{/gist_id}","starred_url":"https://api.github.com/users/janovesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janovesk/subscriptions","organizations_url":"https://api.github.com/users/janovesk/orgs","repos_url":"https://api.github.com/users/janovesk/repos","events_url":"https://api.github.com/users/janovesk/events{/privacy}","received_events_url":"https://api.github.com/users/janovesk/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T13:52:36Z","updated_at":"2015-11-18T13:52:36Z","body":"Hi, @bording! Status is that fix is code complete for hotfix-5.0.8, hotfix-5.1.6, hotfix-5.2.10. I'll port it the latest changes to hotfix-4.7.9 later tonight combined with milestoned issues. \r\n\r\nHopefully releasable tomorrow."}}