MS WCF通信 [英] MS WCF communication

查看:98
本文介绍了MS WCF通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
在WCF中工作以在2个进程之间进行通信.我需要它们之间的某种队列系统.所以我选择MSMQ.

说明:清空队列后,它正在工作.我需要它来同步.当它在队列中接收第一条消息时,它将启动调度程序,这将清空队列.如果队列中有多个消息,它将为每个消息启动一个新的调度程序.这意味着在尚未完成其工作的调度程序之间将存在并发行为.

问题:我希望一个调度员完成工作并在完成后关闭,并希望一个调度员开始接受下一条消息.我希望调度程序工作于同步模式.我是否有可以完成此操作的属性或可以进行的其他调整?

致以最诚挚的问候

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

推荐答案

为什么不直接与MSMQ一起使用?

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[Serializable]类型.

mq.BeginReceive();再次启用OnReceiveCompleted的asych调用,从那时起启用并行执行.

据我所能确定的那样,这将以所需的方式进行.

问候
Espen Harlinn



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


为什么不直接使用MSMQ?
由于似乎存在服务器问题,因此我将在此处回答您的问题.
WCF是未来. WCF将所有功能COM,MSMQ…聚集在一个屋顶下,因此它们可以与一个接口一起工作. MS正在尝试实现面向服务的新方向.
如果您得到了答案,我将不知所措
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


查找ServiceBehaviorAttribute并尝试将InstanceContextMode设置为PerCall-如果可以接受的性能开销是这样做的一种方法.. .-Espen Harlinn 36分钟前

谢谢.我来看看.
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.


这篇关于MS WCF通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆