Sample applications
To run your own .NET applications, use the instructions for the verification programs, substituting our application name in place of the sample applications.
Five sample applications are supplied:
- A put message application
- A get message application
- A 'hello world' application
- A publish/subscribe application
- An application using message properties
All these sample applications are supplied in the C# language, and some are also supplied in C++ and Visual Basic. We can write applications in any language supported by .NET.
- "Put message" program SPUT (nmqsput.cs, mmqsput.cpp, vmqsput.vb)
- This program shows how to put a message to a named queue. The program has three parameters:
If no queue manager name is given, the queue manager defaults to the default local queue manager. If a channel is defined, it has the same format as the MQSERVER environment variable.
- The name of a queue (required), for example, SYSTEM.DEFAULT.LOCAL.QUEUE
- The name of a queue manager (optional)
- The definition of a channel (optional), for example, SYSTEM.DEF.SVRCONN/TCP/hostname(1414)
- "Get message" program SGET (nmqsget.cs, mmqsget.cpp, vmqsget.vb)
- This program shows how to get a message from a named queue. The program has three parameters:
If no queue manager name is given, the queue manager defaults to the default local queue manager. If a channel is defined, it has the same format as the MQSERVER environment variable.
- The name of a queue (required), for example, SYSTEM.DEFAULT.LOCAL.QUEUE
- The name of a queue manager (optional)
- The definition of a channel (optional), for example, SYSTEM.DEF.SVRCONN/TCP/hostname(1414)
- "Hello World" program (nmqwrld.cs, mmqwrld.cpp, vmqwrld.vb)
- This program shows how to put and get a message. The program has three parameters:
If no queue name is given, the name defaults to SYSTEM.DEFAULT.LOCAL.QUEUE. If no queue manager name is given, the queue manager defaults to the default local queue manager.
- The name of a queue (optional), for example, SYSTEM.DEFAULT.LOCAL.QUEUE or SYSTEM.DEFAULT.MODEL.QUEUE
- The name of a queue manager (optional)
- A channel definition (optional), for example, SYSTEM.DEF.SVRCONN/TCP/hostname(1414)
- "Publish/subscribe" program (MQPubSubSample.cs)
- This program shows how to use IBM MQ publish/subscribe. It is supplied in C# only. The program has two parameters:
- The name of a queue manager (optional)
- A channel definition (optional)
- "Message properties" program (MQMessagePropertiesSample.cs)
- This program shows how to use message properties. It is supplied in C# only. The program has two parameters:
- The name of a queue manager (optional)
- A channel definition (optional)
We can verify your installation by compiling and running these applications.
The sample applications are installed to the following locations, according to the language in which they are written. MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.
- C#
MQ_INSTALLATION_PATH\Tools\dotnet\samples\cs\nmqswrld.cs
MQ_INSTALLATION_PATH\Tools\dotnet\samples\cs\nmqsput.cs
MQ_INSTALLATION_PATH\Tools\dotnet\samples\cs\nmqsget.cs
MQ_INSTALLATION_PATH\Tools\dotnet\samples\cs\MQPubSubSample.cs
MQ_INSTALLATION_PATH\Tools\dotnet\samples\cs\MQMessagePropertiesSample.cs
- Managed C++
MQ_INSTALLATION_PATH\Tools\dotnet\samples\mcp\mmqswrld.cpp
MQ_INSTALLATION_PATH\Tools\dotnet\samples\mcp\mmqsput.cpp
MQ_INSTALLATION_PATH\Tools\dotnet\samples\mcp\mmqsget.cpp
- Visual Basic
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\vmqswrld.vb
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\vmqsput.vb
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\vmqsget.vb
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\xmqswrld.vb
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\xmqsput.vb
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\xmqsget.vb
To build the sample applications a batch file has been supplied for each language.
- C#
MQ_INSTALLATION_PATH\Tools\dotnet\samples\cs\bldcssamp.bat
The bldcssamp.bat file contains a line for each sample, which is all that is necessary to build this sample program:csc /t:exe /r:System.dll /r:amqmdnet.dll /lib: MQ_INSTALLATION_PATH\bin /out:nmqwrld.exe nmqwrld.cs- Managed C++
MQ_INSTALLATION_PATH\Tools\dotnet\samples\mcp\bldmcpsamp.bat
The bldmcpsamp.bat file contains a line for each sample, which is all that is necessary to build this sample program:cl /clr:oldsyntax MQ_INSTALLATION_PATH\bin mmqwrld.cppIf you want to compile these applications on Microsoft Visual Studio 2003/.NET SDKv1.1, replace the compile command:cl /clr:oldsyntax MQ_INSTALLATION_PATH\bin mmqwrld.cppwithcl /clr MQ_INSTALLATION_PATH\bin mmqwrld.cpp- Visual Basic
MQ_INSTALLATION_PATH\Tools\dotnet\samples\vb\bldvbsamp.bat
The bldvbsamp.bat file contains a line for each sample, which is all that is necessary to build this sample program:vbc /r:System.dll /r: MQ_INSTALLATION_PATH\bin\amqmdnet.dll /out:vmqwrld.exe vmqwrld.vb