Sun Java System Message Queue 4.2 Developer's Guide for C Clients

Preface

This book provides programming and reference information for developers working with Sun JavaTM System Message Queue (formerly SunTM ONE Message Queue) 4.2, who want to use the C language binding to the Message Queue Service to send, receive, and process Message Queue messages.

Who Should Use This Book

This guide is for developers who want to use the C-API in order to write C or C++ messaging programs that can interact with the Message Queue broker to send and receive JMS messages.

This book assumes that readers are experienced C or C++ programmers and that they are familiar with the Java Message Service specification.

Before You Read This Book

You must read the Sun Java System Message Queue 4.2 Technical Overviewto become familiar with Message Queue’s implementation of the Java Message Service specification, with the components of the Message Queue service, and with the basic process of developing, deploying, and administering a Message Queue application.

How This Book Is Organized

This guide is designed to be read from beginning to end. The following table briefly describes the contents of each chapter.

Table P–1 Book Contents

Chapter 

Description 

Chapter 1, Introduction

Introduces the C-API, provides quick start instructions on compiling and building Message Queue C clients. Introduces the Message Queue C-Client sample applications that are shipped with Message Queue, and explains how you set up your environment to run these examples. Provides a deployment worksheet. 

Chapter 2, Using the C API

Explains how you use the C-API to construct, to send, to receive, and to process messages. This chapter also covers error handling, memory management, and logging. 

Chapter 3, Client Design Issues

Explains the major considerations that you need to keep in mind when designing a Message Queue C client. 

Chapter 4, Reference

Provides complete reference information for the Message Queue C-API: data structures and functions. It also lists and describes the contents of the C-API header files. 

Appendix A, Message Queue C API Error Codes

Lists the code and descriptive string returned for errors that are returned by C library functions. 

Related Documentation

The information resources listed in this section provide further information about Message Queue in addition to that contained in this manual.

Message Queue Documentation Set

The documents that comprise the Message Queue documentation set are listed in the following table in the order in which you might normally use them. These documents are available through the Sun documentation Web site at

Click “Software,” followed by “Application & Integration Services,” and then “Message Queue.”

Table P–2 Message Queue Documentation Set

Document 

Audience 

Description 

Sun Java System Message Queue 4.2 Technical Overview

Developers and administrators 

Describes Message Queue concepts, features, and components. 

Sun Java System Message Queue 4.2 Release Notes

Developers and administrators 

Includes descriptions of new features, limitations, and known bugs, as well as technical notes. 

Sun Java System Message Queue 4.2 Installation Guide

Developers and administrators 

Explains how to install Message Queue software on Solaris, Linux, and Windows platforms. 

Sun Java System Message Queue 4.2 Developer’s Guide for Java Clients

Developers 

Provides a quick-start tutorial and programming information for developers of Java client programs using the Message Queue implementation of the JMS or SOAP/JAXM APIs. 

Sun Java System Message Queue 4.2 Administration Guide

Administrators, also recommended for developers 

Provides background and information needed to perform administration tasks using Message Queue administration tools. 

Sun Java System Message Queue 4.2 Developer’s Guide for C Clients

Developers 

Provides programming and reference documentation for developers of C client programs using the Message Queue C implementation of the JMS API (C-API). 

Sun Java System Message Queue 4.2 Developer’s Guide for JMX Clients

Administrators 

Provides programming and reference documentation for developers of JMX client programs using the Message Queue JMX API. 

Online Help

Message Queue 4.2 includes command-line utilities for performing Message Queue message service administration tasks.

Message Queue 4.2 also includes a graphical user interface (GUI) administration tool, the Administration Console (imqadmin). Context-sensitive help is included in the Administration Console; see Administration Console Online Help in Sun Java System Message Queue 4.2 Administration Guide.

JavaDoc

JMS and Message Queue API documentation in JavaDoc format is provided at the following location:

Platform 

Location 

Solaris 

/usr/share/javadoc/imq/index.html

Linux 

/opt/sun/mq/javadoc/index.html

Windows 

IMQ_HOME/javadoc/index.html

This documentation can be viewed in any HTML browser. It includes standard JMS API documentation, as well as Message Queue-specific APIs for Message Queue administered objects, which are of value to developers of messaging applications.

Example Client Applications

Message Queue provides a number of example client applications to assist developers.

Example Java Client Applications

Example Java client applications are located in the following directories, depending on platform. See the README files located in these directories and their subdirectories for descriptive information about the example applications.

Platform 

Location 

Solaris 

/usr/demo/imq/

Linux 

/opt/sun/mq/examples

Windows 

IMQ_HOME/demo/

where IMQ_HOME is the Message Queue home directory

Example C Client Programs

Example C client applications are located in the following directories, depending on platform. See the README files located in these directories and their subdirectories for descriptive information about the example applications.

Platform 

Location 

Solaris 

/opt/SUNWimq/demo/C/

Linux 

/opt/sun/mq/examples/C/

Windows 

IMQ_HOME/demo/C/

where IMQ_HOME is the Message Queue home directory

Example JMX Client Programs

Example Java Management Extensions (JMX) client applications are located in the following directories, depending on platform. See the README files located in these directories and their subdirectories for descriptive information about the example applications.

Platform 

Location 

Solaris 

/opt/SUNWimq/demo/imq/jmx

Linux 

/opt/sun/mq/examples/jmx

Windows 

IMQ_HOME\demo\jmx

where IMQ_HOME is the Message Queue home directory

The Java Message Service (JMS) Specification

The JMS specification can be found at the following location:

The specification includes sample client code.

The SOAP with Attachments API for Java (SAAJ) Specification

The SOAP with Attachments API for Java (SAAJ) Specification can be found at the following location:

http://java.sun.com/xml/downloads/saaj.html

The specification includes sample client code.

Books on JMS Programming

For background on using the JMS API, you can consult the following publicly-available books:

Directory Variable Conventions

Message Queue makes use of three directory variables; how they are set varies from platform to platform. One of these is relevant to C clients. Table P–3 describes this variable and how it is used on the Solaris, Linux, and Windows platforms.


Note –

The information in Table P–3 applies only to the standalone installation of Message Queue. When Message Queue is installed and run as part of an Application Server installation, the value of the directory variable is set differently: IMQ_HOME is set to appServer_install_dir/imq (where appServer_install_dir is the Application Server installation directory.)


Table P–3 Directory Variable Conventions

Variable 

Description 

IMQ_HOME

Used in Message Queue documentation to refer to the Message Queue base directory (root installation directory): 

  • On Solaris and Linux, there is no root Message Queue installation directory. Therefore IMQ_HOME is not used in Message Queue documentation to refer to file locations in Solaris and Linux.

  • On Windows, the root Message Queue installation directory is set to the directory in which you unzip the Message Queue bundle.

In this guide, IMQ_HOME, IMQ_VARHOME, and IMQ_JAVAHOME are shown without platform-specific environment variable notation or syntax (for example, $IMQ_HOME on UNIX). Path names generally use UNIX directory separator notation (/).

Typographic Conventions

The following table describes the typographic conventions that are used in this book.

Table P–4 Typographic Conventions

Typeface 

Meaning 

Example 

AaBbCc123

The names of commands, files, and directories, and onscreen computer output 

Edit your .login file.

Use ls -a to list all files.

machine_name% you have mail.

AaBbCc123

What you type, contrasted with onscreen computer output 

machine_name% su

Password:

aabbcc123

Placeholder: replace with a real name or value 

The command to remove a file is rm filename.

AaBbCc123

Book titles, new terms, and terms to be emphasized 

Read Chapter 6 in the User's Guide.

A cache is a copy that is stored locally.

Do not save the file.

Note: Some emphasized items appear bold online.

Shell Prompts in Command Examples

The following table shows the default UNIX® system prompt and superuser prompt for the C shell, Bourne shell, Korn shell, and Windows operating system.

Table P–5 Shell Prompts

Shell 

Prompt 

C shell 

machine_name%

C shell for superuser 

machine_name#

Bourne shell and Korn shell 

$

Bourne shell and Korn shell for superuser 

#

Windows 

C:\ 

Symbol Conventions

The following table explains symbols that might be used in this book.

Table P–6 Symbol Conventions

Symbol 

Description 

Example 

Meaning 

[ ]

Contains optional arguments and command options. 

ls [-l]

The -l option is not required.

{ | }

Contains a set of choices for a required command option. 

-d {y|n}

The -d option requires that you use either the y argument or the n argument.

${ }

Indicates a variable reference. 

${com.sun.javaRoot}

References the value of the com.sun.javaRoot variable.

Joins simultaneous multiple keystrokes. 

Control-A 

Press the Control key while you press the A key. 

Joins consecutive multiple keystrokes. 

Ctrl+A+N 

Press the Control key, release it, and then press the subsequent keys. 

-> 

Indicates menu item selection in a graphical user interface. 

File -> New -> Templates 

From the File menu, choose New. From the New submenu, choose Templates. 

Documentation, Support, and Training

The Sun web site provides information about the following additional resources:

Searching Sun Product Documentation

Besides searching Sun product documentation from the docs.sun.com web site, you can use a search engine by typing the following syntax in the search field:


search-term site:docs.sun.com

For example, to search for “broker,” type the following:


broker site:docs.sun.com

To include other Sun web sites in your search (for example, java.sun.com, www.sun.com, and developers.sun.com), use “sun.com” in place of “docs.sun.com” in the search field.

Third-Party Web Site References

Third-party URLs are referenced in this document and provide additional, related information.


Note –

Sun is not responsible for the availability of third-party web sites mentioned in this document. Sun does not endorse and is not responsible or liable for any content, advertising, products, or other materials that are available on or through such sites or resources. Sun will not be responsible or liable for any actual or alleged damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods, or services that are available on or through such sites or resources.


Sun Welcomes Your Comments

Sun is interested in improving its documentation and welcomes your comments and suggestions. To share your comments, go to http://docs.sun.com and click Send Comments. In the online form, provide the full document title and part number. The part number is a 7-digit or 9-digit number that can be found on the book's title page or in the document's URL. For example, the part number of this book is 819-7756.