Starting the Publisher Client and Sending Messages

Setting up the publisher is very similar to setting up the subscriber. However, while the subscriber requires the name of the topic and the user, the publisher also requires messages.

To start the publisher:

Procedure

  1. In the third command line window, navigate to the EMS_HOME/samples/java folder.
  2. Enter setup to set the environment and classpath:
    > setup
  3. Execute the tibjmsMsgProducer client to direct user1 to publish some messages to the myTopic topic:
    > java tibjmsMsgProducer -topic myTopic -user user1 hello user2

    where ’hello' and ’user2’ are separate messages.

    Note: In this example, user1 is both a publisher and subscriber.

Result

The command line window will display a message stating that both messages have been published:

   Publishing on topic 'myTopic'
   Published message: hello
   Published message: user2

After the messages are published, the command window for the publisher returns to the prompt for further message publishing.

Note: Note that if you attempt to use the form:
java tibjmsMsgProducer -topic myTopic -user user1

without adding the messages, you will see an error message, reminding you that you must have at least one message text.

The first and second command line windows containing the subscribers will show that each subscriber received the two messages:

Subscribing to destination: myTopic

Received message: TextMessage={ Header={ JMSMessageID={ID:EMS-SERVER.16C5B5C81B3CB4:1} JMSDestination={Topic[myTopic]} JMSReplyTo={null} JMSDeliveryMode={PERSISTENT} JMSRedelivered={false} JMSCorrelationID={null} JMSType={null} JMSTimestamp={Thu Mar 07 18:18:01 CST 2019} JMSDeliveryTime={Thu Mar 07 18:18:01 CST 2019} JMSExpiration={0} JMSPriority={4} } Properties={ JMSXDeliveryCount={Integer:1} } Text={hello} }
Received message: TextMessage={ Header={ JMSMessageID={ID:EMS-SERVER.16C5B5C81B3CB4:2} JMSDestination={Topic[myTopic]} JMSReplyTo={null} JMSDeliveryMode={PERSISTENT} JMSRedelivered={false} JMSCorrelationID={null} JMSType={null} JMSTimestamp={Thu Mar 07 18:18:01 CST 2019} JMSDeliveryTime={Thu Mar 07 18:18:01 CST 2019} JMSExpiration={0} JMSPriority={4} } Properties={ JMSXDeliveryCount={Integer:1} } Text={user2} }