ASFClient1.java

 

This application acts as a client of the WebSphere MQ JMS ASF. It sets up a single ConnectionConsumer to consume the messages in a single WebSphere MQ queue. It displays throughput statistics for each message listener that is used, and terminates after one minute.

The application can either retrieve the required administered objects from a JNDI namespace, or create them explicitly, using the WebSphere MQ JMS classes that implement these interfaces. The administered objects that are required are a QueueConnectionFactory and a queue.

This application has two versions of the command line syntax:

For use with JNDI, the syntax is:

java -Djava.library.path=library_path
     ASFClient1 [-icf jndiICF] [-url jndiURL] [-qcfLookup qcfLookup]
                [-qLookup qLookup] [-poolSize poolSize] [-batchSize batchSize]
where library_path is the path to the WebSphere MQ Java libraries (see The WebSphere MQ Java libraries).

For use without JNDI, the syntax is:

java -Djava.library.path=library_path
     ASFClient1 -nojndi [-qmgr qMgrName] [-q qName]
                        [-poolSize poolSize] [-batchSize batchSize]

Table 1 describes the parameters and gives their defaults.

ASFClient1 parameters and defaults
Parameter Meaning Default
jndiICF Initial context factory class used for JNDI com.sun.jndi.ldap.LdapCtxFactory
jndiURL Provider URL used for JNDI ldap://localhost/o=ibm,c=us
qcfLookup JNDI lookup key used for QueueConnectionFactory cn=qcf
qLookup JNDI lookup key used for Queue cn=q
qMgrName Name of queue manager to connect to "" (use the default queue manager)
qName Name of queue to consume from SYSTEM.DEFAULT.LOCAL.QUEUE
poolSize The number of ServerSessions created in the ServerSessionPool being used 5
batchSize The maximum number of message that can be assigned to a ServerSession at a time 10

The application obtains a QueueConnection from the QueueConnectionFactory.

A ServerSessionPool, in the form of a MyServerSessionPool, is constructed using:

The connection's createConnectionConsumer method is invoked, passing in:

The consumption of messages is then started by invoking the connection's start() method.

The client application displays throughput statistics for each message listener that is used, displaying statistics every 10 seconds. After one minute, the connection is closed, the server session pool is stopped, and the application terminates.


uj25710_