{"action":"created","issue":{"url":"https://api.github.com/repos/Particular/NServiceBus/issues/3242","labels_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3242/labels{/name}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3242/comments","events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3242/events","html_url":"https://github.com/Particular/NServiceBus/pull/3242","id":122536051,"number":3242,"title":"[SPIKE] Proposal CancellationTokenSource for pipeline cancellation","user":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"labels":[{"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:%20Spike","name":"Type: Spike","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-12-16T15:50:39Z","updated_at":"2015-12-18T12:47:58Z","closed_at":"2015-12-18T12:47:58Z","pull_request":{"url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3242","html_url":"https://github.com/Particular/NServiceBus/pull/3242","diff_url":"https://github.com/Particular/NServiceBus/pull/3242.diff","patch_url":"https://github.com/Particular/NServiceBus/pull/3242.patch"},"body":"I hacked together a quick spike (doesn't even compile) to show I new concept I would like to discuss. I quickly showed it in the @Particular/tf-async-transport sync today.\r\n\r\nSo instead of pulling in #3220 we could extend the `PushContext` so that the transport has to pass in a `CancellationTokenSource` per push operation. This allows the core to cancel the token source for FLR purposes instead of throwing an opaque `MessageProcessingAbortedException`. This makes the seam more intention revealing.\r\n\r\nThere are many more advantages to this approach:\r\n\r\n* We can create linked token sources which get cancelled when the transport is shutdown, therefore allowing the pipeline to cancel inflight receives where possible\r\n* The token can be passed over the context into the user code. What is great about that is that almost all async APIs support `CancellationToken`. Therefore when a receive is cancelled we can also abort the user code (if they decide to opt in for that)\r\n* The transport decides what it wants to do with the `CancellationTokenSource`. We could even forsee transports that define `CancelAfter(TimeSpan span)` on the cancellation token source and therefore the source auto cancels based on predefined settings (like PeekLock, TransactionSettings...)\r\n\r\n@Particular/tf-async-transport @Particular/tf-asyncawait @Particular/nservicebus Thoughts? Should we go with that?\r\n"},"comment":{"url":"https://api.github.com/repos/Particular/NServiceBus/issues/comments/165770283","html_url":"https://github.com/Particular/NServiceBus/pull/3242#issuecomment-165770283","issue_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3242","id":165770283,"user":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T12:47:58Z","updated_at":"2015-12-18T12:47:58Z","body":"Closing spike"}}