The MSMQReceiver component is used to receive messages from MSMQ. The component supports different formatters used by sending client applications to serialise object messages written to queue. The name of the queue from which a message needs to be retrieved can be specified using the Configuration Property Sheet (CPS).
Points to note
- If a queue specified in the CPS does not exist in a local or remote MSMQ server, it is not automatically created.
- This component runs only on Windows Platform.
- This component requires Microsoft .NET Framework 3.5 or above installed on the machine where peer server is running.
- To receive messages sent from MSMQSender component, configure the component for ActiveXMessageFormatter.
- The component returns message content as it is for messages whose body is of String type and for other types uses XMLSerializer to serialize objects into XML format and return the content. Hence the component supports receiving messages of types that can be serialized/deserialized using XMLSerializer. For more information on XMLSerializer refer to http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx
- Transactional remote receive can be performed in the context of a local Distributed Transaction Coordinator (MS DTC) transaction.
The MSMQ server, queue and formatters can be configured in the CPS.
Figure 1: MSMQReceiver5.0 Configuration CPS
Error Handling Configuration
Please refer Error Handling section Common Configurations page.for details.
Use Connection Details from input
If 'yes', adapter will use configuration details from input request, if any property is not provided, corresponding value provided in this panel will be used. This is an Expert Property.
Provide MachineName in case of OS protocol, IPAddress in case of TCP protocol and NetworkNumber; HostNumber in case of SPX.
Name of the Queue to which a component needs to be connected to.
Name of the Queue to which a component needs to be connected to; choose form the following options available:
Protocol to be used. Use 'OS' to access with MachineName and 'TCP' to access with IPAddress.
Options available are:
Specifies whether the queue is transacted or not.
Using Transactional Remote Receive
To use transactional remote receive, you need to configure both the Queue Computer and the Client Computer to enable network DTC access. The steps to do this are as follows:
- Open the Control Panel, open Administrative Tools, and open Component Services
- In Component Services, in the left pane, click the Component Services node, then click the Computers node. In the right pane, right-click My Computer and select Properties from the context menu. This will open the My Computer Properties dialog box.
- In the My Computer Properties dialog box, select the MSDTC tab, and click the Security Configuration... button in the Transaction Configuration group at the lower left. This will open the Security Configuration dialog box.
- In the Security Configuration dialog box, check the Network DTC Access checkbox. This will enable the Client and Administration and Transaction Manager Communication groups.
To enable Network DTC and configure Windows firewall on Windows7 or Windows Server 2008 R2
- Click Start, click Run, type dcomcnfg and then click OK to open Component Services.
- In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, click to expand Distributed Transaction Coordinator and then click Local DTC.
- Right click Local DTC and click Properties to display the Local DTC Properties dialog box.
- Click the Security tab.
- Set the following options on the Security tab of the Local DTC Properties dialog box and click OK.
- In the Transaction Manager Communication group, check the Allow Inbound and Allow Outbound check boxes, and select the Mutual Authentication Required radio button.
- Click OK to close the Security Configuration dialog box. This will pop up a DTC Console Message dialog box that asks if you want to stop and restart the MS DTC service. Click Yes.
- Click OK to close the My Computer Properties dialog box.
You also need to configure Windows Firewall to add MS DTC to the list of exceptions. The steps to do this are as follows:
- Open the Control Panel and open Windows Firewall.
- In the Windows Firewall dialog box, select the Exceptions tab.
- Click the Add Program button and add Msdtc.exe, which is typically found in your Windows\System32 directory.
Receive mode, type of formatter to be used to receive messages and associated properties are to be configured here.
Receive Operation Mode
Select Asynchronous mode to receive messages as soon as it is available on queue. In synchronous mode, one message will be read from queue after receiving input or after every configured interval in case of scheduling mode.
Figure 2: Message Configuration section with Asynchronous mode selected
Should wait ?
Select 'yes' to wait for specified period or no for infinite time while receiving message.
Figure 3: Message Configuration section with 'Should Wait?' property set as 'yes'
Wait time (milli sec)
Time period to wait before appropriate action to be taken
Action when message is not available
Action to be taken when message is not available on queue before the specified time out, in case of EMPTY_MESSAGE_ACTION empty message will be sent to output port, an error will be sent to error port in case of ERROR_ACTION
Type of formatter to be used. MSMQReceiver supports three type of formatters.
This formatter has to be used to receive messages whose body are serialised using a format that is compatible with the MSMQ ActiveX Component. The ActiveXMessageFormatter is compatible with messages sent using Message Queuing COM components, allowing interoperability with applications that use the MSMQ COM control. MSMQReceiver component supports only primitive data types for ActiveXMessageFormatter
This formatter has to be used to receive messages whose body are serialised using a binary format. The BinaryMessageFormatter is very efficient and can be used to serialize most objects. The objects which are marked as serializible can be used with this formatter. With MSMQReceiver component to receive messages of non primitive data types, Assembly(dll) containing the particular class type should be explicitly added as a resource to the component. The component after receiving the message, will output object content in XML Format
This formatter has to be used to receive messages whose body are serialised using a XML format. The XmlMessageFormatter is the default formatter that an instance of MessageQueue uses to serialize messages written to the queue. With MSMQReceiver component to receive messages of non primitive data types, Assembly(dll) containing the particular class type whose schema matches to the sender type should be explicitly added as a resource to the component. The name of the assembly and comma seperated fully namespace qualified class names (e.g com.fiorano.TestMessage) or primitive type names(string, int etc) should be provided in Assembly Name and Class Name properties respectively in the CPS of the component. The component after receiving the message, will output object content in XML Format
Figure 4: Message Configuration section with 'Message Formatter' property set as 'XMLMessageFormatter'
Name of the assembly (along with extension, that is, Test.dll) containing class types that will be available on queue.
Comma-separated values of Namespace qualified class name of possible message types (e.g: fiorano.csharp.Test, string). In case of primitive data types, provide keywords of corresponding type (like string, int).
Please refer the respective section in the MSMQSender5.0 page for the information about this property.
The input schema is auto generated on input port for SYNCHRONOUS receive operation and when the property "Use Connection Details from input" is set to "yes" as shown below
Figure 5: Input Schema.
Figure 6: Sample Input XML.
Receive messages from a local MSMQ Server.
Configure the MSMQ Receiver in scheduling mode and provide required assemblies for XMLMessageFormatter and use Display component to check the response.
Figure 7: Sample Output
Figure 8: Demonstrating Scenario 1 with sample output.