This chapter describes how to develop, run, and manage MessageQ Client applications. It contains the following topics:
Note:
OpenVMS users must execute: DMQ$DISK:[DMQ$V40.EXE]DMQ$CL_SET_LNM_TABLE
before building or running client applications. Refer to Post-installation Tasks in Chapter 2 for more information.
This section describes the following special considerations for developing applications to run on the MessageQ Client:
Developing Your MessageQ Client Application
Table 4-1 shows the API functions supported by the MessageQ Client. A small number of MessageQ API functions are available only for a specific environment and are not supported by the MessageQ Client. For example, the MessageQ API Support
pams_get_msga
function is available only on OpenVMS systems. To learn about the MessageQ API functions, see the MessageQ Programmer's Guide.
The MessageQ Client sets specific limits on function parameter values that allow very large arguments on MessageQ Server systems. The limits for the function parameters reduces the size of network messages exchanged between the MessageQ Client and the remote Client Library Server. Table 4-2 lists the functions, parameters and their maximum values on the MessageQ Client.
Note: Messages larger than 32,700 bytes can be sent or received by using the semantics for handle-based messages (PSYM_MSG_HANDLE) or large messages (PSYM_MSG_LARGE). Refer to the MessageQ Programmer's Guide for information on how to send these kinds of messages.
The MessageQ Client provides include files for C and C++ language programs. The include files contain the MessageQ API function prototype declarations, return status codes, symbolic constants used for API parameters, and other declarations for using MessageQ message-based services. Table 4-3 lists the standard MessageQ include files, which are described in the MessageQ Programmer's Guide. The default location for these include files is:
DMQ$DISK:[DMQ$V40.USER.TEMPLATE]
All MessageQ return codes are defined in the include file, p_return.h
. Some of the return codes are specific to the MessageQ Client and are not returned to server-based applications.
Table 4-4 lists the return codes specific to the MessageQ Client.
There are platform-specific differences in the numeric values for the p_return.h
return codes. The OpenVMS version of p_return.h
contains numeric values different from those used on Windows NT, Windows 95, OS/2, or UNIX. Client applications do not need to be concerned with these differences because the MessageQ Client returns status codes as they are defined on the client system, regardless of the system where the CLS is running.
It is recommended that programs use the symbolic value when testing the return status codes, rather than a numeric value. For example,
if ( status == PAMS__NETNOLINK )
instead of
if ( status == -278 )
This improves code portability because of the platform-specific differences in the numeric values listed in p_return.h
. It also makes code maintenance easier in the event that any status code numeric value is changed.
MessageQ provides the capability to send and receive messages between many different types of operating systems and CPU architectures. The byte order used by different CPU architectures is referred to as either little endian (or right-to-left order) or big endian (left-to-right order). Application designers must take into account the differences in byte ordering when designing a distributed application with MessageQ.
The byte order used on the MessageQ Client system and the CLS platform may be different. For example, a Windows PC with an Intel x86 CPU is a little endian machine and an HP PA-RISC system is a big endian machine. This means that integer values sent in the message area from the client are represented differently when received by the application server on the host.
The MessageQ Client and CLS handle differences in byte ordering by using network byte order when the Client and Server system are based on different representations (network byte order is big endian.). This ensures that the arguments to the MessageQ API functions called on the client are passed correctly to CLS platform to initiate the messaging operation.
Note:
The MessageQ Client does not perform byte-swapping on the user data passed in the message area for pams_put_msg
or pams_get_msg
calls. Only MessageQ self-describing messages perform data marshaling between systems with unlike endian formats. Refer to the MessageQ Programmer's Guide for more information about how to use self-describing messages.
There are various techniques for handling the byte order differences in the client or server application components:
The data marshaling routines can be implemented as a set of library routines designed specifically to support data format conversion. These routines are typically written so that each marshal routine performs one specific record conversion. Standard socket routines are available to support byte-order conversion. These routines are On OpenVMS systems, developers use the following syntax to compile MessageQ Client C application programs:
The Client applications can be linked with either:
htonl
, htons
, ntohl
, and ntohs
. For example, htonl
means host to network long (32-bit) conversion.
Building Your Client Applications
$ cc MY_DMQ_PROGRAM/INCLUDE=DMQ$USER:
/INCLUDE
option for this command is used to specify the location of MessageQ header files.
Linking applications with the MessageQ RTL allows code sharing between numerous simultaneous users. It also saves memory, disk space, and link time. Applications linked with the MessageQ for OpenVMS RTL can run in the MesssageQ for OpenVMS Server environment simply by redefining the DMQ$ENTRYRTL logical name.
Applications linked with the MessageQ OLB must be relinked if they are moved to a MessageQ Server system. The files required for linking are located in the DMQ$LIB and DMQ$USER directories.
To link an application with the RTL, use the DMQ$LIB:DMQ/OPT switch in the linker command line. For example, to link a program called MY_DMQ_PROGRAM with the MessageQ Client RTL you would use the following command:
The options file contains all the commands needed to build an application with the MessageQ Client RTL. The DMQ$LIB:DMQ.OPT file uses the DMQ$ENTRYRTL logical to identify the RTL.
The choice of RTL will determine which network transports are available for the client application. For example, DMQ$EXE:DMQ$DECNET_CLRTLV40.EXE supports only DECnet.
If you have TCP/IP installed, the installation procedure will link an RTL supporting each TCP/IP stack and DECnet. The RTL names and supported transports are shown in the following table. Linking Applications with the MessageQ Runtime Library
$ link MY_DMQ_PROGRAM, DMQ$LIB:DMQ/OPT
The syntax for linking an application with the MessageQ Client OLB is shown in the following example:
$ link MY_DMQ_PROGRAM, DMQ$LIB:CL.OLB/LIBRARY/INCLUDE=(QIO TCPIP option)
In the previous command, the /INCLUDE=(QIO_TCPIP_option) is used to select the desired TCP/IP stack. The following table shows the possible choices for QIO_TCPIP_option.
The MessageQ Client is distributed with a number of sample application programs that demonstrate many features of the MessageQ API. If the sample programs were selected during installation, they will be located in the MessageQ installation directory tree. The default location is:
DMQ$EXAMPLES
The sample programs consist of C language source modules. The sample programs are identical to the sample programs distributed with the MessageQ Server products, which demonstrate the portability of the MessageQ API across all supported platforms.
The command procedure DMQ$EXAMPLES:X_BUILD.COM
is used to build the sample programs. Copy the X_*.C
sample programs and X_BUILD.COM
from DMQ$EXAMPLES
to a personal development directory before modifying any of the files. Use the following command to compile and link the sample programs
$ @x_build
Note that the command procedure DMQ$DISK:[DMQ$V40.EXE]DMQ$CL_SET_LNM_TABLE
must be executed before developing or running a client application on OpenVMS. The syntax for this command is
$ @DMQ$DISK:[DMQ$V40.EXE]DMQ$CL_SET_LNM_TABLE
This command procedure defines logical names to identify files or directories used in development and run-time environments. It also defines symbols for the MessageQ Client utility programs. Users can execute this command procedure from their login procedure (LOGIN.COM
). This procedure must also be executed for any client application that is run as a detached process or batch job.
Client applications are linked with the MessageQ Client run-time library (RTL). Run-time libraries allow code sharing between numerous simultaneous users. It also saves memory, disk space, and link time. The files required for linking are located in the DMQ$LIB and DMQ$USER directories.
To link an application, use the DMQ$LIB:DMQ/OPT
switch in your linker command line. For example, to link a program called MY_DMQ_PROGRAM
with the MessageQ Client, you would use the following command:
$ link MY_DMQ_PROGRAM, DMQ$LIB:DMQ/OPT
The options file contains all the commands needed to build an application with the MessageQ Client RTL.
This topic explains how to run your applicationwith MessageQ Client. Before attempting to run a MessageQ Client application, verify that the TCP/IP or DECnet connection between the MessageQ Client and Server is properly configured. Use the ping
utility to check the TCP/IP connection (see the documentation for TCP/IP networking for your system for more information). Use the ncp tell
command to check the DECnet connection.
To use the MessageQ Client, your run-time environment must meet the following software requirements:
hosts
files on both the
MessageQ Client and Server. Table 4-7 shows the location of host files on all
MessageQ Servers.
For a complete description of MessageQ Server and TCP/IP transports supported by the MessageQ Client, see the MessageQ for OpenVMS Release Notes.
The run-time configuration file, dmq.ini
, is required to run a client application. This file can be located in the application's working directory, or in a location identified by the DMQCL_INI_FILE logical name. The definition of DMQCL_INI_FILE must include the file name. For example, if several users want to share a dmq.ini
file located in a directory called TEST$DISK:[TEST_ENV.DMQ], they would each define DMQCL_INI_FILE as follows:
$ define DMQCL_INI_FILE TEST$DISK:[TEST_ENV.DMQ]DMQ.INI
The MessageQ Client includes several utility programs for testing client applications and managing the MessageQ Client environment. The default location for the utilities is:
DMQ$EXE
Refer to Table 4-8 for a list of the MessageQ Client utilities.
The MessageQ Client MRS utility lets you view the contents of local SAF journals. When a sender program running on the MessageQ Client sends a message marked as recoverable, it is written to the SAF journal on the client system. In the event that the recoverable message cannot be delivered to the CLS on the MessageQ Server and stored by the MessageQ message recovery system, it can be resent at a later time from the SAF journal on the MessageQ Client using this utility.
The MRS utility is started with the following command:
dmqclmrsu [-h | -v | -d | -l | -nmessage
| -tmessage
] [-fsaf_path
]
Listing 4-1 shows the MessageQ Client MRS utility using the -l
and the -n
options.
Listing 4-1 MessageQ Client MRS Utility
/usr/users/smith/dmq > dmqclmrsu -l
SAF journal: dmqsaf.jrn
Msg Source Target Class Type Pri Size Data...
----- ----------- ----------- ------ ------ --- ------ ------------
1 0.0 5.300 66 99 0 13 'first mess'
2 0.0 5.300 66 99 0 14 'second mes'
3 0.0 5.300 66 99 0 13 'third mess'
4 0.0 5.300 66 99 0 14 'fourth mes'
5 0.0 5.300 66 99 0 13 'fifth mess'
6 0.0 5.300 66 99 0 13 'sixth mess'
7 0.0 5.300 66 99 0 15 'seventh me'
8 0.0 5.300 66 99 0 14 'eighth mes'
9 0.0 5.300 66 99 0 13 'ninth mess'
10 0.0 5.300 66 99 0 13 'tenth mess'
/usr/users/smith/dmq > dmqclmrsu -n 7
SAF journal: dmqsaf.jrn
Detail of message: 7
Source: 0.0 Priority: 0 Size: 15 Large_Size: 0
Target: 5.300 Class: 66 Type: 99
Resp Q: 0.0 Delivery: 29 UMA: 5 Timeout: 100
Contents of message buffer:
XB 73, 65, 76, 65, 6E, 74, 68, 20, 6D, 65 ! 'seventh me'
XB 73, 73, 61, 67, 65 ! 'ssage'
The MessageQ Client Event Watcher utility is a program that provides a console window to view the messaging activity of the MessageQ Client at run time. Tracing large messages to the Event Watcher will slow system performance. Event Watcher messages longer than 5000 bytes are truncated to minimize IPC resource usage. Note that large messages logged to the message trace file (dmqtrace.log) are not truncated.
To use the Event Watcher, follow these steps:
Where:
dmqclwatch [-h | -v ]
-h
Prints a brief help message-v
Displays the version number
Listing 4-2 shows the MessageQ Client Event Watcher window.
Listing 4-2 MessageQ Client Event Watcher
/usr/users/smith/dmq > dmqclwatch
MessageQ CL Event Watcher 4.0.001 waiting for messages...
MSG ! Message sent Fri Dec 20 10:17:32 1996
SOURCE = 7.423 TARGET = 7.423
CLASS = 66 TYPE = 99
XB 66, 69, 72, 73, 74, 20, 6D, 65, 73, 73 ! 'first mess'
XB 61, 67, 65 ! 'age'
EOM
MSG ! Message received Fri Dec 20 10:17:37 1996
SOURCE = 7.423 TARGET = 7.423
CLASS = 66 TYPE = 99
XB 66, 69, 72, 73, 74, 20, 6D, 65, 73, 73 ! 'first mess'
XB 61, 67, 65 ! 'age'
EOM
Messages can be traced to both the Event Watcher and to the log file, dmqtrace.log
. Messages can also be traced to the log file without running the Event Watcher. Transmitted messages can be logged and traced independently of received messages. Refer to Configuring Tracing in Chapter 3 for more information about trace file settings.