diff options
author | Lee, Tian (tl5884) <tianl@amdocs.com> | 2018-02-05 10:17:48 +0000 |
---|---|---|
committer | Lee, Tian (tl5884) <tianl@amdocs.com> | 2018-02-05 10:17:48 +0000 |
commit | 0556bc61f7cb201974cbcb66fa9d82b8d27c50bc (patch) | |
tree | 87650b00af8f30a4bafbe52681d830a7b621b058 /docs/Event Client API Documentation/EventClientAPI_Beijing.rst | |
parent | 4150ee34ae503c83734aca7e62ca9911b354c881 (diff) |
Initial draft of Event Client documentation
In RST format
Change-Id: I52ecc7523aa0af3735d8417cb5edca1460252f2f
Issue-ID: AAI-700
Signed-off-by: Lee, Tian (tl5884) <tianl@amdocs.com>
Diffstat (limited to 'docs/Event Client API Documentation/EventClientAPI_Beijing.rst')
-rw-r--r-- | docs/Event Client API Documentation/EventClientAPI_Beijing.rst | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/docs/Event Client API Documentation/EventClientAPI_Beijing.rst b/docs/Event Client API Documentation/EventClientAPI_Beijing.rst new file mode 100644 index 0000000..3d5e2c7 --- /dev/null +++ b/docs/Event Client API Documentation/EventClientAPI_Beijing.rst @@ -0,0 +1,128 @@ +DMaaP Client based API +====================== + +ONAP Gerrit repo: \ https://gerrit.onap.org/r/#/admin/projects/aai/event-client + +This is a thin API library based on the DMaaP Client, and exposes +methods that can be used to publish and consume JSON messages to/from a +DMaaP topic. + +Importing the library +===================== + +To add the Event Bus Client Library to your project simply include the +following dependencies in your project's pom.xml. Note that +the httpclient dependency may be required in your project pom if you are +also depending on AJSC artifacts, as they use an earlier version of +the httpclient which may overwrite the later version required by the +library. + +<dependency> + +<groupId>org.onap.aai.event-client</groupId> + +<artifactId>event-client-dmaap</artifactId> + +<version>1.2.0-SNAPSHOT</version> + +</dependency> + +<!-- This dependency is required if you also have AJSC dependencies --> + +<dependency> + +<groupId>org.apache.httpcomponents</groupId> + +<artifactId>httpclient</artifactId> + +<version>4.5.2</version> + +</dependency> + +<!-- This dependency is required if you also have AJSC dependencies --> + +**Note** - In order to retrieve all of the client's transitive +dependencies you may need to configure your maven settings.xml with the +ONAP repositories. + +Publishing +========== + +Here is an example of how to use the client to publish a message to the +DMaaP topic. + +DMaaPEventPublisher eventPublisher = new DMaaPEventPublisher(host, +topic, username, password); + +try { + +int result = eventPublisher.sendSync(partition, messages); + +// result should equal number of messages supplied to sendSync + +} catch (...) { + +} finally { + +List<String> unsentMessages = eventPublisher.closeWithUnsent() + +// Handle unsent messages + +} + +**host** - The host URL to use to connect to the DMaaP topic, in the +form of <host:port>. + +**topic** - The topic name to publish to. This must be an existing DMaaP +topic. + +**username** - The MechID of the calling application. + +**password** - The password for the MechID. + +**partition** - The partition to publish the message to. + +**message** - A List of JSON String messages to publish as a batch. + +Consuming +--------- + +Here is an example of how to use the client to consume messages from the +UEB. + +try { + +DMaaPEventConsumer consumer = new DMaaPEventConsumer(host, topic, +username, password, consumerGroup, consumerId) + +Iterable<String> messages = consumer.consume(); + +for(String message : messages) { + +// process message + +} + +} catch(...) {} + +**host** - The host URL to use to connect to the DMaaP topic, in the +form of <host:port>. + +**topic** - The topic name to consume from. This must be an existing +topic. + +**username** - The MechID of the calling application. + +**password** - The password for the MechID. + +**consumerGroup** - The name of the consumer group this consumer is part +of. + +**consumerId** - The unique id of this consumer in its group. + +Creating Topics and Authentication +================================== + +For information about creating and managing DMaaP topics, refer to the +`DMaaP DBCAPI <https://gerrit.onap.org/r/#/admin/projects/dmaap/dbcapi>`__ +project documentation. |