Link to home
Start Free TrialLog in
Avatar of raynera
raynera

asked on

WCF Service That Responds to Messages Arriving in MSMQ

Hi all

I can't figure out how to set this up. I can post messages into my MSMQ with no issues, however I cannot figure out how to setup/build a WCF service that is invoked whenever a new queue item appears…

I've got a WCF service with the interface setup thus :

[OperationContract(IsOneWay=true)]
void ReadQueue(TQueueItem myQueueItem);

And the service itself is :

public void ReadQueue(TQueueItem myQueueItem))
  {
     Some code in here that processes myQueueItem
  }

myQueueItem is basically a custom class that I attach to my MSMQ message.

I've then got an Application added under the Default Website with netMsmqBinding setup on it. The service itself is configured as per Tom Hollanders blog :

http://blogs.msdn.com/b/tomholl/archive/2008/07/12/msmq-wcf-and-iis-getting-them-to-play-nice-part-1.aspx

I'm developing using VS2012 on a Windows7 machine. Just trying to get it running locally first.

I've got MSMQ setup on my local machine and have a number of queued messages in the queue I'm hoping my WCF service will process.

I must be missing something somewhere. Does anyone have a walkthrough that shows all the configuration steps? I'm pulling my hair out!
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Simply putting it... you can't!

Webservices, like webpages, are designed to wait for actions, not to start them.
An outside entity must perform a request to a WCF Service for it to work, otherwise it will never start or do things by himself.

What you need is actually a windows service that will periodically check the MSMQ.
Then you can make this windows service call an hypothetical ProcessMQ() method of the WCF that reads and processes all messages in the queue.
Avatar of raynera
raynera

ASKER

I thought that's what the Windows Activation Service was for? To be able to kickstart a WCF service when something lands in a queue? At least that's what I'd got from reading stuff on the web :/

If that assumption is wrong too I'll do what you say...and write a plain old windows brokering service.
Oh snap... I completely forgot about WAS.
But if you're going on that route I can't really help you because I never actually implemented anything with it.

Anyway... I think I still like the idea of developing my own windows service instead :)

Good luck!
Avatar of raynera

ASKER

I guess I stumped everyone? Don't want to write a brokering service :(
ASKER CERTIFIED SOLUTION
Avatar of raynera
raynera

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raynera

ASKER

Found a solution online.
As you accepted your own answer, can you post your solution (not just a link)?

As it stands, this question is pretty much useless to anyone.

Thanks!
Avatar of raynera

ASKER

Do I take it that you need the solution to the problem? Or are you just being picky?!
I'm being picky :)

In my opinion either we delete the question of if there's an accepted answer it should in fact represent an answer.
As it stands, someone that bumps into this gets no added value.
Avatar of raynera

ASKER

Yeh I know. When I get chance to package it up I'll do it.