0

I am self hosting a WCF service in a Windows Service which has two endpoints. TCP one is attached to one interface implementation, and MSMQIntegration one is attached to another interface implementation.

I would like to build functionality that would allow me to suspend the MSMQ endpoint for a period of time (so that it stops looking for messages on the queue), and then build another that would allow me to re-enable it. I want to do this without out stopping the ServiceHost and not interfering with the TCP endpoint at all.

I have tried to remove the endpoint from ServiceHost.Description.Endpoints, but I can't add it back in later. I think maybe there can be something done with the ChannelDispatcher, but I am not real sure on what to do.

The reason that I am not running two ServiceHosts is because the TCP interface's method are there to report on the status and throughput of the MSMQ endpoint. Also (in the future), I would like to add methods to the TCP interface that would allow an admin to dynamically configure the MSMQ endpoint on the fly, without shutting down and restarting the MSMQ endpoint. If the TCP ServiceHost is different than the MSMQ I am not sure how to keep variable scope for reporting and configuration.

SO..basically I am looking to suspend a listener, and not to shut it off and start it back up again. How can I achieve this?

David P
  • 2,027
  • 3
  • 15
  • 27
  • Why not have two `ServiceHost`s? Then you can stop one without affecting the other –  Nov 18 '14 at 23:59
  • Let me try to explain. The MSMQ endpoint does the bulk of the work for the service. The TCP endpoint points to interface methods that are more utility and reporting based, like reporting on the throughput of the service (how many messages processed, average size of messages, average time to process a message). If I have a different ServiceHost for the MSMQ endpoint then how would the TCP methods have access to the information the MSMQ endpoint is processing? – David P Nov 19 '14 at 13:23
  • Thanks. Could you update the question? –  Nov 19 '14 at 13:25
  • I attempted to look at: http://stackoverflow.com/questions/547287/stop-start-wcf-mex-service-at-runtime I adjusted the MEX Dispatcher example to get rid of my MSMQ one. It seemed to work to some extent, but not completely. Once I removed the Dispatcher, and sent a message to the queue, the operationmethod didnt trigger. I'm thinking good. Unfortunately, the message was still taken off the queue. Thats bad. Anybody got any ideas? – David P Nov 19 '14 at 21:15
  • Perhaps a WCF transaction? –  Nov 21 '14 at 07:01
  • I was able to not have the message picked off the queue if I closed the ChannelDispatcher. Only question now, is how to restart the ChannelDispatcher. Wehn I try to Open it again, it says it can't do it since its a disposed object. – David P Dec 08 '14 at 19:28

0 Answers0