Sample applications

Three sample applications are supplied:

"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 3 parameters:

  • 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)

If no queue manager name is given, the queue manager defaults to the default local queue manager. If a channel is defined, it should have the same format as the MQSERVER

environment variable

.

"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 3 parameters:

  • 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)

If no queue manager name is given, the queue manager defaults to the default local queue manager. If a channel is defined, it should have the same format as the MQSERVER

environment variable

.

"Hello World" program (nmqwrld.cs, mmqwrld.cpp, vmqwrld.vb)

This program shows how to put and get a message. The program has 3 parameters:

  • 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)

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.

We can verify your installation by compiling and running these applications.

The sample applications will be installed to the following locations, according to the language in which they are written, where mqmtop represents the high-level directory in which the product has been installed:

C#

mqmtop\Tools\dotnet\samples\cs\nmqswrld.cs

mqmtop\Tools\dotnet\samples\cs\nmqsput.cs

mqmtop\Tools\dotnet\samples\cs\nmqsget.cs

Managed C++

mqmtop\Tools\dotnet\samples\mcp\mmqswrld.cpp

mqmtop\Tools\dotnet\samples\mcp\mmqsput.cpp

mqmtop\Tools\dotnet\samples\mcp\mmqsget.cpp

Visual Basic

mqmtop\Tools\dotnet\samples\vb\vmqswrld.vb

mqmtop\Tools\dotnet\samples\vb\vmqsput.vb

mqmtop\Tools\dotnet\samples\vb\vmqsget.vb

mqmtop\Tools\dotnet\samples\vb\xmqswrld.vb

mqmtop\Tools\dotnet\samples\vb\xmqsput.vb

mqmtop\Tools\dotnet\samples\vb\xmqsget.vb

To build the sample applications a batch file has been supplied for each language.

C#

mqmtop\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:mqmtop\bin 
/out:nmqwrld.exe nmqwrld.cs

Managed C++

mqmtop\Tools\dotnet\samples\mcp\bldmcpsamp.bat

The bldmcpamp.bat file contains a line for each sample, which is all that is necessary to build this sample program:

cl /clr mqmtop\bin mmqwrld.cpp

Visual Basic

mqmtop\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:mqmtop\bin\amqmdnet.dll /out:vmqwrld.exe vmqwrld.vb


csq870w