The MSMQ Message Service adapter is a message adapter that lets Flex applications subscribe to MSMQ queues.
When a Flex Producer component sends (Producer.send) a message to a destination serviced by an MSMQ adapter FluorineFx delivers the message into the queue. (The body of each Flex message is delivered to the queue). For subscribed consumers each time a message is received in the queue FluorineFx will push the message to the clients.
The sample uses 2 queues: "orderqueuein" is used to place orders and "orderqueuenotifications" for receiving notifications
<destination id="orderProcessor">
<adapter ref="msmqAdapter"/>
<properties>
<msmq>
<name>.\private$\orderqueuein</name>
</msmq>
</properties>
</destination>
...
<destination id="orderNotifications">
<adapter ref="msmqAdapter"/>
<properties>
<msmq>
<name>.\private$\orderqueuenotifications</name>
</msmq>
</properties>
</destination>
The sample Flex client will place orders by sending messages to the "orderProcessor" destination:
var order:Order = new Order(); order.Product = "Bolts"; order.Quantity = 10; order.User = username; var message:AsyncMessage = new AsyncMessage(); message.body = order; producer.send(message); ... <mx:Producer id="producer" destination="orderProcessor"/> ...
Order objects stored in the Flex message body will be delivered into the "orderqueuein" queue. From here a sample back-end application reads the orders, each order is processed (the sample just sets the ID of the order object) then a notification message is sent to the "orderqueuenotifications" queue.
Once messages are available in the "orderqueuenotifications" queue FluorineFx will deliver them to Flex clients. You can filter messages by using the Consumer component's selector property.
consumer.selector = "User = '" + username + "'"; consumer.subscribe(); ... <mx:Consumer id="consumer" destination="orderNotifications"/> ...
The sample sets a selector for filtering messages based on the "User" property so only notifications for orders placed by the current user are received. The "User" variable in the selector expression is a property of the "Order" type. Please note that all the public members of the message body will be available for selector expressions.
When a message is pushed to Consumers the following headers are set:
| Header name | Value |
|---|---|
MSMQId |
MSMQ message Id |
MSMQLabel |
MSMQ message label |
body member |
MSMQ message body members (public properties and fields) For example if an Order object is serialized in the MSMQ message body with ID and Product properties then these will be available in the Flex message headers |
See Also