Como faço para definir a prioridade no lado do cliente da mensagem do MSMQ enviada a um serviço WF ativado via MQ

StackOverflow https://stackoverflow.com//questions/9633251

Pergunta

Eu tenho uma configuração de serviço de fluxo de trabalho ativado WCF (xamlx) (hospedado usando Workflowservicehost).

Este Webservice WCF tem uma ligação 'NetMsMQBinding' e um nó net.msmq baseado em nó que é usado pelos clientes para agendar operações.

No lado do cliente, usei o Visual Studio para gerar o esboço do proxy para se comunicar a este serviço WCF.Tudo está funcionando bem e eu posso ver as mensagens aparecendo no meu (diário) MQ no servidor e WCF picking mensagens da fila para ativar o fluxo de trabalho configurado com base na mensagem.

Eu preciso controlar a prioridade das mensagens que estão sendo enviadas para o MQ para que certos clientes do WCF possam obter o processamento priorizado de seus fluxos de trabalho.

Parece que o netmsmqbinding não suporta a priorização da mensagem do MQ.Isso está correto?Se sim, como posso alcançar / simular isso?Posso usar os triggers do MQ para alterar a prioridade das mensagens com base em alguns sinalizadores?

Foi útil?

Solução

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

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top