我有一个wcf激活的工作流服务(xamlx)设置(托管使用workflowservosthost)。

此WCF WebService具有“NetmsmqInding”绑定和基于Net.msmq的终端点,该端点由客户端来计划操作。

在客户端,我已经使用Visual Studio生成代理存根以与此WCF服务进行通信。一切正常工作正常,我可以看到服务器上的(日志)MQ中出现的邮件和WCF从队列中拾取消息,以根据消息激活配置的工作流程。

我需要控制发送到MQ的消息的优先级,以便某些WCF客户端可以获得其工作流程的优先处理。

似乎netmsmqbinding无法真正支持MQ消息优先级。这样对吗?如果是这样,我如何实现/模拟这一点?我可以使用MQ触发器根据一些标志更改消息的优先级吗?

有帮助吗?

解决方案

Posting my solution, in case someone needs to figure this out

NetMSMQBinding does not support setting message priority from the client side so I was using the wrong binding. The more powerful MsMqIntegrationBinding is the right way to go.

Client side: From the client side, one needs to simply create a System.Messaging.Message object, set the priority and drop it in the MessageQueue.MessageQueue object which points to the destination MQ.

Server side: The WorkflowService hosting WCF project needs the following endpointBinding in the web.config:


<endpoint address="msmq.formatname:DIRECT=OS:.\private$\MyWebService/MyProcessingService.xamlx" binding="msmqIntegrationBinding" bindingConfiguration="MyMsMqIntegrationBinding" contract="IMyProcessingService" name="MqIntegrationBindingEndPoint" />

(the address is assuming MQ service is local to the WCF hosted)

<bindings> <!--We use msmqIntegrationBinding instead of netMsmqBinding since we want to control priority of MQ messages being dropped in the queue and that is not supported in netMsmq --> <msmqIntegrationBinding> <binding name="MyMsMqIntegrationBinding" exactlyOnce="false"> <security mode="None" /> </binding> </msmqIntegrationBinding>


The way to receive the MsmqMessage from the MQ and process it is by dropping a "Receive" activity in the XAMLX and choosing Message as the Content definition MessageType as System.ServiceModel.MsmqIntegrationMessage<YourTypeGoesHere> Now you'll have access to this MsmqMessage<yourType> from your ActivityContext where you can retrieve the value sent in the message.

This is a very useful and powerful way to build a scalable, throttled with priority control MQ+WCF+WF based web service

其他提示

Are these transactional messages? If so, you cannot change the priority at all.

Messages are immutable so you can't change the priority of a non-transactional message that has already been sent.

Cheers
John Breakwell

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top