Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
working in WCF to communicate between 2 processes. I need some kind of Queue system between them. So I choose MSMQ.

Explanation: When the queue is emptied it is working asynchronies. I need it to work synchronies. When it takes first message in queue it starts a dispatcher, this empties the queue. If there is more than one message in queue it will start a new dispatcher for each of the messages. This means that there will be a concurrence behavior between dispatchers that are not finished with its work.

Question: I want one dispatcher to work and close when finished and a new to start to take the next message. I want dispatcher to work synchronies mode. I´s there any attribute that can accomplish this or some other adjustment that can be made?

Best regards to you all
Posted

Why not work with MSMQ directly?

private void OnReceiveCompleted(Object source,
       ReceiveCompletedEventArgs asyncResult)
{
    try
    {
	MessageQueue mq = (MessageQueue)source;
	
	if (mq != null)
	{
	  Message message = null;
	  try
	  {
	    message = mq.EndReceive(asyncResult.AsyncResult);
	  }
	  catch (Exception ex)
	  {
	    ....
	  }
          // Enable OnReceiveCompleted event
          mq.BeginReceive();  

	  if (message != null)
	  {
	    QueuedDeviceInput queuedInput = 
                          message.Body as QueuedDeviceInput;
	    if (queuedInput != null)
	    {
              .....
	    }
	  }
	}
	return;
    }
    catch (Exception exc)
    {
	...
    }
}


QueuedDeviceInput is a [Serializable] type.

mq.BeginReceive(); enable asych invocation of OnReceiveCompleted once more, enabling paralell execution from that point on.

This will, as far as I'm able to determine from your question, behave in the required manner.

Regards
Espen Harlinn
 
Share this answer
 
Why not work with MSMQ directly?
As there seems to be an serverproblem, I will answer your question here.
WCF is the future. WCF gather every function COM, MSMQ… under one roof, so they can work together with one Interface. MS is trying to implement the new orientation, which is Service orientated.
If you got an answer I’m all ears
 
Share this answer
 
Comments
Espen Harlinn 15-Jan-11 10:27am    
Look up the ServiceBehaviorAttribute and try to set InstanceContextMode to PerCall - if the performance overhead is acceptable that's one way to do it ...
Look up the ServiceBehaviorAttribute and try to set InstanceContextMode to PerCall - if the performance overhead is acceptable that's one way to do it ... - Espen Harlinn 36 mins ago

Thanks. I will have a look at that.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900