0

I am wondering if there is a way to do the following:

main WCF service is in a class lib which gets invoked / bound to MSMQ. Have a seperate Console app which hosts the service.

2 different projects. Of course the console app references the class lib which processes messages.

I want custom handling of poison messages. No problem, I can create an attribute and decorate this ontop of the service itself and then have a custom class which implements IErrorHandler and move the message. This is all in the class lib

Problem: in order for the service to continue processing messages, the service host must be restarted.

But not possible because the class lib does not (nor should it!) have a reference to the console app which hosts the service.

what is the best way of restarting the client? I was thinking maybe there is a way to attach at runtime the attribute and errorhandler, which would be moved to the console app project and then when the service is being created to maybe attach the attribute at runtime in someway? or am I getting carried away?

tom redfern
  • 30,562
  • 14
  • 91
  • 126
Ahmed ilyas
  • 5,722
  • 8
  • 44
  • 72
  • 2
    I'm not understanding why the service host needs to be restarted when a poison message arrives. Doesn't your IErrorHandler code protect it from crashing? – Mike Parkhill Sep 27 '12 at 02:10
  • well, you would think so! It at least gives me more control on what I can do with that message (i.e move it somewhere else altogether!). But apperently not. Also take a look at the code: http://msdn.microsoft.com/en-us/library/vstudio/ms751472(v=vs.90).aspx - you will see it placing a call to the StartService on the threadpool to restart the service host – Ahmed ilyas Sep 27 '12 at 02:21
  • 1
    You are reading the MSMQ 3.0 example which is for old versions of the OS with poor poison message support. Read the next example for MSMQ 4.0: http://msdn.microsoft.com/en-us/library/vstudio/aa395218(v=vs.90).aspx – ErnieL Sep 27 '12 at 05:09
  • Thanks ErnieL. I certainly did this, so it moves the poison msg to the local poison queue and continues to run the service host normally which is GREAT. I would however like the flexibility to move that msg to another queue somewhere else and think the MSMQ 3.0 example would be the way to go... but have the problem as I indicated above :) – Ahmed ilyas Sep 27 '12 at 19:41

0 Answers0