Wednesday, November 3, 2010 send messages to multiply locations using MessageQueueGatewaySupport

Use Case

My service utilizing MessageQueueGatewaySupport need to send messages to multiply locations (queues) which are not known at design time.


Prepare generic application context configuration (see post: dynamic configuration. Configure IApplicationContext from GenericApplicationContext and file stream. for more details).

On runtime, you can programmatically register queues as shown below:

            // Get template
            var template = Context["messageQueueTemplate"] as MessageQueueTemplate;

                       var mq = new MessageQueue();
                       mq.Path = requestQueuePath;
                       return mq;

            template.ConvertAndSend(requestQueueName, request, delegate(Message message)
                   // do smth with your message
                   return message;

No comments:

Post a Comment