Just a second...

Java

The Java™ API is provided as a JAR file for Oracle® Java Development Kit 8 (minimum update 1.8.0_131-b11).

Get the Java client libraries using Maven™:

Add the Push Technology public repository to your pom.xml file:
<repositories>
    <repository>
        <id>push-repository</id>
        <url>https://download.pushtechnology.com/maven/</url>
    </repository>
</repositories>
Declare the following dependency in your pom.xml file:
<dependency>
    <groupId>com.pushtechnology.diffusion</groupId>
    <artifactId>diffusion-client</artifactId>
    <version>version</version>
</dependency>

Get the Java client libraries using Gradle:

Add the Push Technology public repository to your build.gradle file:
repositories { maven { url "http://download.pushtechnology.com/maven/" } }
Declare the following dependency in your build.gradle file:
compile 'com.pushtechnology.diffusion:diffusion-client:6.2.0'

Get the Java client libraries:

The ZIP file is also located in your Diffusion™ server installation:
diffusion_directory/clients/java/diffusion-client-6.2.0.jar

Capabilities

To see the full list of capabilities supported by the Java API, see Feature support in the Diffusion API.

Support

Table 1. Supported platforms and transport protocols for the client libraries
Platform Minimum supported versions Supported transport protocols
Java Oracle Java Development Kit 8 (minimum update 1.8.0_131-b11)

Oracle Java SE 9.0.4, 10.0.1, or 11.0.1

OpenJDK 9.0.4, 10.0.2, 11.0.1

Note: Later patch releases of each version are also supported.

WebSocket

HTTP (Polling)

Resources

Using

Certificates

Diffusion Java clients use certificates to validate the security of their connection to the Diffusion server. The client validates the certificate sent by the Diffusion server against the set of certificates trusted by the Java Development Kit (JDK).

If the certificate sent by the Diffusion server cannot be validated against any certificates in the set trusted by the JDK, you receive an exception that contains the following message: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

Diffusion is authenticated using the certificates provided by your certificate authority for the domain you host the Diffusion server on.

To ensure that the certificate is validated, set up a trust store for the client and add the appropriate certificates to that trust store:
  1. Obtain the appropriate intermediate certificate from the certificate authority.
  2. Use keytool to create a trust store for your client that includes this certificate.

    For more information, see https://docs.oracle.com/cd/E19509-01/820-3503/ggfka/index.html

  3. Use system properties to add the trust store to your client.
    For example:
    System.setProperty("javax.net.ssl.trustStore", "truststore_name");
    Or at the command line:
    -Djavax.net.ssl.keyStore=path_to_truststore
Writing good callbacks
The Java client library invokes callbacks using a thread from Diffusion thread pool. Callbacks for a particular session are called in order, one at a time. Consider the following when writing callbacks:
  • Do not sleep or call blocking operations in a callback. If you do so, other pending callbacks for the session are delayed. If you must call a blocking operation, schedule it in a separate application thread.
  • You can use the full Diffusion API to make other requests to the server. If you want to make many requests based on a single callback notification, be aware that Diffusion client flow control is managed differently in callback threads. Less throttling is applied and it is easier to overflow the servers by issuing many thousands of requests. If you have a lot of requests to make, it is better to schedule the work in an application thread.
Regular expressions

The Java client uses the same regular expression engine to the Diffusion server. Some regular expressions in topic selectors are evaluated on the client and others on the Diffusion server. There is no difference in how these regular expressions are evaluated in the Java client.