52 MQSeries Publish/Subscribe Applications
4.2.5 Defining MQSeries required for the application
In order to run the Public Transport application, a few MQSeries objects (queues
and server connection) must be created. In the additional material accompanying
this book, we provide the MQSC script called vehicle.mqsc containing the
definitions for these objects. You should run this script against a queue manager.
You may decide to create a new queue manager or to use an existing one. Run
the script with the command runmqsc QMGR_NAME < vehicle.mqsc, where
QMGR_NAME is the name of the queue manager. If you want to create these objects
on the default queue manager, you can use the command runmqsc <
vehicle.mqsc.
4.2.6 AMI overview
The Application Messaging Interface (AMI) API is one of the latest additions to
the MQSeries API portfolio, AMI has very interesting features and a different
approach. Given that AMI will be used extensively throughout the book, we
provide a very brief overview of its most important aspects. Complete information
about this API can be found in MQSeries Application Messaging Interface,
SC34-5604.
Key features and concepts
The key features of AMI are:
򐂰 Provides a higher level, easy-to-use interface to messaging.
򐂰 Reduces to a minimum the number and complexity of data structures and
parameters.
򐂰 Increases the number of API verbs in order to accommodate each messaging
style (send and forget, request/reply, publish/subscribe) in the best way.
򐂰 Provides reasonable API structure for procedural languages like C and
COBOL, as well as object-oriented ones like C++ and Java.
򐂰 Moves middleware-specific options out of the application domain and into the
administration domain by using an external persistent repository.
򐂰 Interoperates seamlessly with any other MQSeries messaging API flavor (for
example Java JMS, and RPG MQI).
The AMI structure and concepts revolve around three main entities: services,
policies and messages. Lets review each of them in turn:
򐂰 A service is the abstraction of an MQSeries queue, assuming that a queue
hosts semantically homogeneous sets of messages being consumed
(served) by an application to satisfy a business need.
Service definitions are stored in the repository.
Chapter 4. The publish/subscribe application 53
򐂰 A policy is a collection of attributes that define how to handle messages from
a quality-of-service point of view (for example priority, persistence,
acknowledgement level), from a recovery point of view (for example error
handling, and retries) or a housekeeping point of view (for example
expiration).
Policy definitions are stored in the repository.
򐂰 A message is an object containing the actual application data and some
ancillary attributes (for example a correlation identifier or coded character set
identifier) that the typical application can often safely ignore.
API set structure
In this section we briefly describe the main objects of the object-oriented flavors
of AMI (C++ and Java). A specific discussion of the C procedural flavor
peculiarities can be found in 4.6.1, Vehicle C AMI program on page 81 where
we explain the C version of the sample Vehicle program.
The most important class is AmSession. This class creates and manages all
other objects providing also the transactional scope for units of work. Session
objects are created using the AmSessionFactory class.
The Connection object is administered via the repository and is not exported at
the application level. It deals with the details of how to actually connect to the
messaging service provider.
The AmMessage object wraps the MQSeries message descriptor and other
optional headers (for example, MQRFH rules and formatting header or MQRFH2
rules and formatting header). Application data may be stored within or outside
the amMessage object instance.
The AmPolicy object wraps all options needed at open, close, send, receive,
publish, subscribe times. There are several methods that can be used to override
policy defaults (for example, setWaitTime for setting message reception timeout).
The last object is the Service object. There are five types of service:
򐂰 AmSender is the abstraction of an MQSeries output queue. It contains the
actual message send method.
򐂰 AmReceiver is the abstraction of an MQSeries input queue. It contains the
actual message receive method.
򐂰 AmDistributionList is a collection of AMI amSender objects. The main
exported method is send.
򐂰 AmPublisher contains an AmSender object and is used to send publication
messages to a publish/subscribe broker via the publish method.

Get MQSeries Publish/Subscribe Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.