MessagingServiceオブジェクトの作成
MessagingServiceインタフェースは、Javaライブラリのすべての機能のエントリ・ポイントです。
MessagingServiceオブジェクトを作成するには、Oracle Messaging Cloud ServiceインスタンスURLとユーザー資格証明をMessagingServiceFactory.getMessagingService()メソッドに指定する必要があります。
MessagingServiceFactory.getMessagingServiceメソッドは2つのパラメータを取ります:
-
MessagingServiceNamespaceオブジェクト -
MessagingServiceCredentialsオブジェクト
MessagingServiceオブジェクトを作成する例
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);
MessagingServiceオブジェクトが作成されると、キュー、トピックおよびメッセージ・プッシュ・リスナーを管理できるようになります。 また、永続サブスクリプションのプロパティをリストし、取得することもできます。
さらに、Javaライブラリを使用してメッセージを送信および受信するためにConnectionFactoryを作成できます。 Javaライブラリで提供されるJMS APIを使用してConnectionFactoryオブジェクトを取得する方法の詳細は、「ConnectionFactory作成API」を参照してください。