You can create a maximum of 3000 topics. APIs are idempotent. If a topic of the same name already exists, the status code 200 is returned. Otherwise, the status code 201 is returned.
You can create a topic using OpenStack4j based on the following code:
Topic topic = osclient.notification().topics().create("topic-name", "display-name");
Add a subscription to a specified topic. If the status of the subscription is unconfirmed, a confirmation message is sent to the subscriber. After confirming the subscription, the subscriber can receive notification messages published to the topic. APIs are idempotent. If the added subscription already exists, the status code 200 is returned. Otherwise, the status code 201 is returned.
You can add a subscription using OpenStack4j based on the following code by specifying tp to topicUrn:
SubscriptionCreate subscribe = SubscriptionCreate.builder().topicUrn("topic-urn").endpoint("firstname.lastname@example.org") .protocol(Protocol.EMAIL).remark("sdk-unittest").build(); Subscription subscription = osclient.notification().subscriptions().subscribe(subscribe);
You can publish messages to a topic. After the message ID is returned, the message has been saved and is to be pushed to the subscribers of the topic. The message format varies depending on the protocol of a subscription.
You can publish a message using OpenStack4j based on the following code:
MessageIdResponse message = osclient.notification().messages().publish("topic-urn", "subject", "message-content");