Java API Developer's Guide
The PubSub+ Messaging API for Java (version 1.7) uses modern interfaces, patterns, and usability in a native Java environment. The PubSub+ Java API offers many of the same features as the PubSub+ Messaging API for JCSMP, but requires minimal setup to provide a streamlined developer experience to develop client applications.
The PubSub+ Java API utilizes the builder pattern, which allows you to easily create a MessagingService
object with a custom configuration that then connects to an event broker. After a successful connection is established, you can send and receive messages using other interfaces provided in the PubSub+ Java API. You can use the PubSub+ Java API to handle scenarios where messages accumulate on internal buffers, referred to as back-pressure. For example, on a client application that sends messages, it is possible to have a scenario where the client application is generating messages faster than the messages can be sent to the event broker, which can happen due to factors such as network congestion.
Here's an overview of how to use the PubSub+ Messaging API for Java after you've set-up your environment:
- Build the
MessagingService
object and configure it using properties to:- connect to an event broker, such as the Hostname and Message VPN
- set the connection properties, such as TLS or compression
- choose an authentication scheme to authenticate to the event broker
-
Send messages to or receive messages from an event broker as follows using these objects:
During the creation of the objects to publish or consume messages, you can configure how to handle when back-pressure occurs. See each section below for more information.
-
A
DirectMessagePublisher
object to publish direct messages. For more information, see Publishing Direct Messages Using the Java API. -
A
PersistentMessagePublisher
object to publish persistent messages (guaranteed messages). For more information, Publishing Persistent Messages Using the Java API -
A
DirectMessageReceiver
object to consume direct messages from an event broker. For more information, see Consuming Direct Messages Using the Java API . -
A
PersistentMessageReceiver
to consume persistent messages (guaranteed messages) , see Consuming Persistent Messages Using the Java API
-
- As part of publishing or subscribing to messages, use
OutboundMessage
andInboundMessage
objects, and handle errors as required via event handlers.
You can reference various sample applications to understand how to use the PubSub+ Java API. For more information, see Using the Java API Examples or review sections of this guide along with the PubSub+ Messaging API for Java reference.
Here's a short video that provides a brief overview of the PubSub+ Java API.