TIBCO Enterprise Message Service™ Java Quick Start
Contents
- Getting Started
- Building and running samples
- Description of sample applications
- Connecting to TIBCO Cloud Messaging
- Related Links
Getting Started
This quick start guide provides basic instructions for writing TIBCO Enterprise Message Service applications in Java for TIBCO Cloud™ Messaging.
- Download the TIBCO Enterprise Message Service sample applications Java.
- Gradle 6.7+ and JDK 1.8 are required to build and run the sample applications.
- Download a client configuration file using the roles REST API or user interface.
- Review the TIBCO Enterprise Message Service javadoc.
Building and running samples
Follow the steps below to build and run the Java samples:
- Unzip
ems-java-samples.zip
- Change directories into
ems-java-samples/
- Build project:
gradle build
- Use
-f
option to specify the configuration file. - Run samples:
gradle EmsConsumer:run --args="-f <full-path-to>/tcm-config.yaml"
Description of sample applications
Producer
The producer demonstrates connecting an EMS Java application to Cloud Messaging and publishing EMS messages on the given topic or queue:
usage: EmsProducer [-c <count>] [-f <config-file>] [-h] [-i <interval>] [-id <client-id>] [-jndi] [-queue <queue>] [-t
<timeout>] [-topic <topic>]
-c,--count <count> the number of messages to send before exiting
-f,--config <config-file> the path to a configuration yaml
-h,--help this usage
-i,--interval <interval> the interval between sends (milliseconds)
-id <client-id> client identifier
-jndi use JNDI to lookup connection factory
-queue <queue> queue to send on
-t,--timeout <timeout> the duration before exiting (seconds)
-topic <topic> topic to send on
Consumer
The consumer demonstrates connecting an EMS Java application to Cloud Messaging, creating a consumer, and receiving EMS messages on the given topic or queue:
usage: EmsConsumer [-ackmode <arg>] [-c <count>] [-f <config-file>] [-h] [-id <client-id>] [-jndi] [-queue <queue>] [-t
<timeout>] [-topic <topic>]
-ackmode <arg> acknowledge mode, default is AUTO (other options: CLIENT, DUPS_OK, NO,EXPLICIT_CLIENT and
EXPLICIT_CLIENT_DUPS_OK)
-c,--count <count> the number of messages received before exiting
-f,--config <config-file> the path to a configuration yaml
-h,--help this usage
-id <client-id> client identifier
-jndi use JNDI to lookup connection factory
-queue <queue> the queue to consume
-t,--timeout <timeout> the duration before exiting (seconds)
-topic <topic> the topic to consume
Connecting to TIBCO Cloud Messaging
The client configuration file contains all the information client applications need to securely connect to TIBCO Cloud Messaging. Generate the client configuration file using the roles REST API or user interface. Generate as many configuration files as needed for each Role.
Note: TIBCO Cloud Messaging samples require a client configuration file to run.
Connection Example
ConnectionFactory factory = new com.tibco.tibjms.TibjmsConnectionFactory(ems_server);
connection = factory.createConnection(ems_username, tcm_authentication_key);
// setting a client id is recommended
connection.setClientID(cmd.getOptionValue("I", "tcmEmsDemoPub"));