MSMQ 메시지의 클라이언트 측의 클라이언트 측에서 MQ 서비스를 통해 활성화 된 WF 서비스로 설정하려면 어떻게합니까?
-
10-12-2019 - |
문제
WCF 활성화 워크 플로우 서비스 (XAMLX) 설정 (WorkFlowServiceHost를 사용하여 호스팅).
이 WCF WebService에는 'netmsmqbinding'바인딩 및 클라이언트가 작업을 예약 할 수있는 net.msmq 기반 엔드 포인트가 있습니다.
클라이언트 측면에서 Visual Studio를 사용 하여이 WCF 서비스와 통신하기 위해 프록시 스텁을 생성했습니다.모든 것이 잘 작동하며 서버에서 내 (저널 된) MQ에 나타나는 메시지와 메시지를 기반으로 구성된 워크 플로를 활성화하기 위해 큐에서 메시지를 선택하여 메시지를 선택할 수 있습니다.
특정 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