About Using the Java Library

Oracle Messaging Cloud Service can be accessed using the Java library.

Topics:

Prerequisites for Using the Java Library

The Oracle Messaging Cloud Service Java library provides all required Java Message Service (JMS) 1.1 functions, plus additional functions related to JMS and Oracle Messaging Cloud Service for sending and receiving messages through the JMS broker. Previous experience using JMS will be helpful.

The following are required to use the Oracle Messaging Cloud Service Java library:

  • An Oracle Messaging Cloud Service instance

  • The oracle.cloud.messaging.api-14.0.X.jar (where X is the number representing the latest version of the Java library)

  • The JMS 1.1 API JAR file

  • A Java Development Kit (JDK) of version 1.6 or greater

How to Use the Java Library

Before you begin using the Java library, be sure to review the following:

To use the Oracle Messaging Cloud Service Java library:

  1. Download the Java library (see Downloading the Oracle Messaging Cloud Service Java SDK).

  2. Add the jar file oracle.messaging.cloud.api-14.0.X.jar (where X is the latest version number of the Java library) to your Java application's class path.

  3. Import the Java library's classes and interfaces into your Java application.

    import javax.jms.*;
    import oracle.cloud.messaging.*;
    import oracle.cloud.messaging.client.*;
    import oracle.cloud.messaging.common.*;
    
  4. Create a MessagingService object.

    A MessagingService object is created from a MessagingServiceFactory. When creating a MessagingService object, a MessagingServiceNamespace object and a MessagingServiceCredentials object must be provided.

    For more information, see Creating a MessagingService Object.

How to Check the version of the Java Library

The Java library is delivered in two identical .jar files — one containing the version number of the Java library in the file name (for example, oracle.cloud.messaging.api-14.0.1.jar,) and one without the version number (for example, oracle.cloud.messaging.api.jar.) You can also obtain the information about the version of the Java library after installation, through the class oracle.cloud.messaging.VersionInfo.

To check the version of the Java library, run the following command:

java -jar <jar name>.

The version number of the Java library is displayed.

The manifest of each of the Java library jars contains the version of the Java library as the Implementation-Version attribute of the oracle.cloud.messaging package.