- CPS-393Getting issue details... STATUS
Spike Description:
Investigate A&AI interface, especially how to register and receive DMaaP Events from A&AI. Investigate filter-options and consider some PoC code.
Background:
When a xNF object is added to A&AI, a DMaaP event, AAI-EVENT is created. A&AI handles the publishing of this event. To be notified of the AAI-EVENT, CPS will need to register on DMaaP Message Router.
DMaaP offers a client plugin called DMaaP Client, which can be found here https://gerrit.onap.org/r/gitweb?p=dmaap/messagerouter/dmaapclient.git;a=tree;f=src/main/java/org/onap/dmaap/mr/client;h=823c8ab4e10beba654ca9d9d3fff4e580a94aa9a;hb=65aaa3eb6fb0de267819431f7831100ec162de92 . This Client can be used to register to a DMaaP event. The PoC code will use this client to show that CPS can listen for and receive DMaaP events.
Proof Of Concept Code:
To use the DMaaP Client we need the following dependency in our pom.xml file.
<dependency> <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId> <artifactId>dmaapClient</artifactId> <version>1.1.12</version> </dependency>
The following builder method is used to create an instance of a DMaaP Consumer Client:
final MRConsumerImpl mrConsumer = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts) .setTopic("AAI-EVENT").setConsumerGroup("onap-cps").setConsumerId("cps-ncmp").setTimeoutMs(10000) .setLimit(1000).setFilter("").setApiKey_username(null) .setApiSecret_password(null).createMRConsumerImpl();
For the Consumer client to be created we need to pass in the values for the following attributes:
Attribute name | Attribute Description | Example |
---|---|---|
setHostPart | The host and port of the DMaaP server in the format <host:port>. This method takes a collection of strings, check example. | Example of HostPart final Collection<String> hosts = new ArrayList<>(); hosts.add("message-router.onap:3904"); |
setTopic | The topic name to consume from | "AAI-EVENT" |
setConsumerGroup | The consumer group to consume from | "onap-cps" |
setConsumerId | The consumer ID of the client | "cps-ncmp" |
setTimeoutMs | Time in ms to wait for messages on the server before returning | 10000 |
setLimit | Maximum number of messages that is returned per fetch | 1000 |
setFilter | A customizable message filter, or null if no filtering is required | null |
setApiKey_username | The username of the client application | null |
setApiSecret_password | The password for the username | null |