MQQメッセージのクライアント側で優先順位を設定する方法MQを介してアクティブ化されたWFサービスに設定されていますか
-
10-12-2019 - |
質問
私はWCF起動ワークフローサービス(xamlx)セットアップ(WorkflowServiceHostを使用してホストされています)。
このWCF WebServiceには、クライアントが操作をスケジュールするために使用される「NetMSMQBinding」バインディングとNet.msmqベースのエンドポイントがあります。
クライアント側では、このWCFサービスと通信するためにProxyスタブを生成するためにVisual Studioを使用しました。すべてがうまく機能しています。
私は、特定のWCFクライアントがワークフローの優先順位を取得できるように、MQに送信されるメッセージの優先順位を制御する必要があります。
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