{"action":"created","issue":{"url":"https://api.github.com/repos/MassTransit/MassTransit/issues/726","repository_url":"https://api.github.com/repos/MassTransit/MassTransit","labels_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/726/comments","events_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/726/events","html_url":"https://github.com/MassTransit/MassTransit/issues/726","id":194605283,"number":726,"title":"Extra ReceiveEndpoints triggering IConsumeMessageObserver","user":{"login":"Pondidum","id":219090,"avatar_url":"https://avatars.githubusercontent.com/u/219090?v=3","gravatar_id":"","url":"https://api.github.com/users/Pondidum","html_url":"https://github.com/Pondidum","followers_url":"https://api.github.com/users/Pondidum/followers","following_url":"https://api.github.com/users/Pondidum/following{/other_user}","gists_url":"https://api.github.com/users/Pondidum/gists{/gist_id}","starred_url":"https://api.github.com/users/Pondidum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pondidum/subscriptions","organizations_url":"https://api.github.com/users/Pondidum/orgs","repos_url":"https://api.github.com/users/Pondidum/repos","events_url":"https://api.github.com/users/Pondidum/events{/privacy}","received_events_url":"https://api.github.com/users/Pondidum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-09T14:09:42Z","updated_at":"2016-12-09T16:00:30Z","closed_at":null,"body":"Hey,\r\n\r\nI am having a problem with some unit tests which rely on an `IConsumeMessageObserver<>`  to log which messages were received. I have attached the minimal repo unit test below.\r\n\r\nExpected Output\r\n```\r\nPre ca640000-286c-6af7-b860-08d4203b6d46\r\nConsumed ca640000-286c-6af7-b860-08d4203b6d46\r\nPost ca640000-286c-6af7-b860-08d4203b6d46\r\n```\r\n\r\nActual Output:\r\n```\r\nPre ca640000-286c-6af7-b860-08d4203b6d46\r\nPre ca640000-286c-6af7-0f0f-08d4203b6d08\r\nPost ca640000-286c-6af7-0f0f-08d4203b6d08\r\nConsumed ca640000-286c-6af7-b860-08d4203b6d46\r\nPost ca640000-286c-6af7-b860-08d4203b6d46\r\n```\r\n\r\nThe root of the problem seems to be a second RecieveEndpoint being registered internally somewhere.  For example in the repro, if you comment out the `cfg.ReceiveEndpoint(queueName, //...`  block, you still get one `Pre` and one `Post` console message.\r\n\r\nI couldn't find anything in the documentation about this, nor a way to un-register any extra `ReceiveEndpoint` calls.  Is this intended behaviour, and if so, what would you recommend as the best way to deal with it?\r\n\r\n```csharp\r\npublic class Scratchpad\r\n{\r\n    [Test]\r\n    public async Task MutlipleConsumerMessages()\r\n    {\r\n        var bus = Bus.Factory.CreateUsingInMemory(cfg =>\r\n        {\r\n            var queueName = \"testQueue\";\r\n\r\n            cfg.ReceiveEndpoint(queueName, e =>\r\n            {\r\n                e.Consumer(() => new MessageConsumer());\r\n                e.UseConcurrencyLimit(1);\r\n            });\r\n        });\r\n\r\n        bus.ConnectConsumeMessageObserver(new TestObserver());\r\n        bus.Start();\r\n\r\n        await bus.Publish(new Message(Guid.NewGuid()));\r\n\r\n        Task.Delay(TimeSpan.FromSeconds(5)).Wait();\r\n    }\r\n\r\n\r\n    class MessageConsumer : IConsumer<Message>\r\n    {\r\n        public Task Consume(ConsumeContext<Message> context)\r\n        {\r\n            Console.WriteLine(\"Consumed {0}\", context.MessageId);\r\n            return Task.FromResult(1);\r\n        }\r\n    }\r\n\r\n    class TestObserver : IConsumeMessageObserver<Message>\r\n    {\r\n        public Task PreConsume(ConsumeContext<Message> context)\r\n        {\r\n            Console.WriteLine(\"Pre {0}\", context.MessageId);\r\n            return Task.FromResult(1);\r\n        }\r\n\r\n        public Task PostConsume(ConsumeContext<Message> context)\r\n        {\r\n            Console.WriteLine(\"Post {0}\", context.MessageId);\r\n            return Task.FromResult(1);\r\n        }\r\n\r\n        public Task ConsumeFault(ConsumeContext<Message> context, Exception exception)\r\n        {\r\n            Console.WriteLine(\"Fault\");\r\n            return Task.FromResult(1);\r\n        }\r\n    }\r\n\r\n    class Message\r\n    {\r\n        public Guid Id { get; }\r\n\r\n        public Message(Guid id)\r\n        {\r\n            Id = id;\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/MassTransit/MassTransit/issues/comments/266049415","html_url":"https://github.com/MassTransit/MassTransit/issues/726#issuecomment-266049415","issue_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/726","id":266049415,"user":{"login":"phatboyg","id":20041,"avatar_url":"https://avatars.githubusercontent.com/u/20041?v=3","gravatar_id":"","url":"https://api.github.com/users/phatboyg","html_url":"https://github.com/phatboyg","followers_url":"https://api.github.com/users/phatboyg/followers","following_url":"https://api.github.com/users/phatboyg/following{/other_user}","gists_url":"https://api.github.com/users/phatboyg/gists{/gist_id}","starred_url":"https://api.github.com/users/phatboyg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phatboyg/subscriptions","organizations_url":"https://api.github.com/users/phatboyg/orgs","repos_url":"https://api.github.com/users/phatboyg/repos","events_url":"https://api.github.com/users/phatboyg/events{/privacy}","received_events_url":"https://api.github.com/users/phatboyg/received_events","type":"User","site_admin":false},"created_at":"2016-12-09T16:00:30Z","updated_at":"2016-12-09T16:00:30Z","body":"So, this is expected behavior. Because there are two receive endpoints, and because you are publishing the message, and because you are using the InMemoryTransport, this is sort of a side effect of that behavior. The \"bus\" is where you are connecting your observer, and the observer connects to all receive endpoints. So the act of connecting the observer makes the message type visible to your observer. Since no message is actually being consumed, you get the Pre/Post, but not the actual Consumed events.\r\n\r\nIf you change it to a Send to the receive endpoint address, you'll only see a single observer sequence.\r\n"}}
{"actor":{"display_login":"phatboyg"}}