The HATopicPublisher and HADurableSubscriber applications
The HATopicPublisher and HADurableSubscriber applications demonstrate how to enable JMS client applications to use Eclipse Amlen high availability features.
These applications are in the com.ibm.ima.samples.jms
package
and are designed to work with each other. The HATopicPublisher publishes
messages to a durable topic and the HADurableSubscriber reads messages
from that topic. These samples show how to use built-in high availability
features in the Eclipse Amlen JMS
client, and how client applications can function with resilience when
the primary server goes down and the standby server becomes the primary
server in a high availability configuration.
- The ability to use the client Server ConnectionFactory property to configure the list of host names (or IP addresses) for the configured high availability servers.
- The ability to use the client isClosed property to determine whether the connection to the server was lost when a failure is reported.
true
. Client applications always check
the isClosed property when failures occur. When
a client application finds that isClosed is true
,
a new connection is created so that processing can continue. You can run the HATopicPublisher application by using the following command. The command consists of five required positional arguments and three more positional arguments that are optional.
java com.ibm.ima.samples.jms.HATopicPublisher serverlist serverport topicname count messagetext [msgspersec] [initdurablesub] [debug]
Where the positional arguments are:
- serverlist
- A string that represents a list of Eclipse Amlen server host names or IP addresses. This list can be comma or space delimited.
- serverport
- An integer value that represents the port number for connections to the Eclipse Amlen server.
- topicname
- A string that represents the name of the topic destination for published messages.
- count
- An integer value that represents the number of messages to publish.
- messagetext
- A string that represents the content of the published messages.
- msgspersec
- Optional.
- initdurablesub
- Optional.
- debug
- Optional.
You can run the HADurableSubscriber application by using the following command. The command consists of four required positional arguments and a fifth positional argument that is optional.
java com.ibm.ima.samples.jms.HADurableSubscriber serverlist serverport topicname count [receivetimeout]
Where the positional arguments are:
- serverlist
- A string that represents a list of Eclipse Amlen server host names or IP addresses. This list can be comma or space delimited.
- serverport
- An integer value that represents the port number for connections to the Eclipse Amlen server.
- topicname
- A string that represents the durable subscription topic name.
- count
- An integer value that represents the number of messages to receive.
- receivetimeout
- Optional.
Examples
The following commands show examples of the arguments that you can use to run the HATopicPublisher application.
This example uses the default values of the optional arguments.
java com.ibm.ima.samples.jms.HATopicPublisher "server1.example.com, server2.example.com" 16102 durableTopic 2000 "Test message"
This
example sets debug to true
rather
than using the default value of false
. This setting
means that debug output is provided. As debug is
a positional argument, the values of msgspersec and
initdurablesub must be specified even when the
default values are used.
java com.ibm.ima.samples.jms.HATopicPublisher "server1.example.com, server2.example.com" 16102 durableTopic 2000 "Test message" 5000 true true
The following commands show examples of the arguments that you can use to run the HADurableSubscriber application.
This example uses the default receivetimeout value of 10 seconds.
java com.ibm.ima.samples.jms.HADurableSubscriber "server1.example.com, server2.example.com" 16102 durableTopic 2000
This example sets the receivetimeout value to 60 seconds.
java com.ibm.ima.samples.jms.HADurableSubscriber "server1.example.com, server2.example.com" 16102 durableTopic 2000 60