Use the .NET Monitor
The .NET Monitor is an application similar to an IBM MQ trigger monitor.
Important: See Features that can be used only with the primary installation on Windows for important information.We can create .NET components which are instantiated whenever a message is received on a monitored queue, and which then process that message. The .NET Monitor is started by the runmqdnm command and stopped by the endmqdnm command. For details of these commands, see runmqdnm and endmqdnm.
To use the .NET Monitor, you write a component that implements the IMQObjectTrigger interface, which is defined in amqmdnm.dll.
Components can be either transactional or non-transactional. A transactional component must inherit from System.EnterpriseServices.ServicedComponent and be registered as either RequiresTransaction or SupportsTransaction. It must not be registered as RequiresNew as the .NET Monitor has already initiated a transaction.
The component receives MQQueueManager, MQQueue, and MQMessage objects from runmqdnm. It may also receive a User Parameter string if one was specified, using the -u command-line option, when runmqdnm was started. Note that your component receives the contents of a message that arrived on the monitored queue in an MQMessage object. It does not have to connect to the queue manager, open the queue, or get the message itself. The component must then process the message as appropriate and return control to the .NET Monitor.
If your component has been written as a transactional component, it registers to commit or roll back the transaction using the facilities provided by System.EnterpriseServices.ServicedComponent.
As the component receives MQQueueManager and MQQueue objects as well as the message, it has complete context information for that message and can, for example, open another queue on the same queue manager without needing to separately connect to IBM MQ.
- Example code fragments
This topic contains two examples of components which obtain a message from the .NET Monitor and print it, one using transactional processing and the other non-transactional processing. A third example shows common utility routines, applicable to both the first two examples. All the examples are in C#.
Parent topic: Writing and deploying IBM MQ .NET programs