Creating a MessagingService
Object
The MessagingService
interface is the entry point for all functionality of the Java library.
To create a MessagingService
object, you must provide an Oracle Messaging Cloud Service instance URL and user credentials to the MessagingServiceFactory.getMessagingService()
method.
The MessagingServiceFactory.getMessagingService
method takes two parameters:
-
A
MessagingServiceNamespace
object -
A
MessagingServiceCredentials
object
Example to create a MessagingService
object
MessagingServiceFactory factory = MessagingServiceFactory.getInstance(); String serviceUrl = "https://messaging.us2.oraclecloud.com/myservice-mydomain"; String username = "john.doe@example.com"; String password = "myPassword"; Namespace namespace = new MessagingServiceNamespace(serviceUrl); Credentials credentials = new MessagingServiceCredentials(username, password); MessagingService service = factory.getMessagingService(namespace, credentials);
Once a MessagingService
object has been created, you can manage queues, topics, and message push listeners. You can also list, and retrieve the properties of durable subscriptions.
In addition you can create a ConnectionFactory
to send and receive messages using the Java library. See ConnectionFactory Creation API for information about how to use the JMS API provided in the Java library to obtain a ConnectionFactory
object.