You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

CPS-393 - Getting 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. 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.

DMaaP Client dependency in pom.xml
    <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:

Example 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 nameAttribute DescriptionExample
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");
setTopicThe topic name to consume from"AAI-EVENT"
setConsumerGroupThe consumer group to consume from"onap-cps"
setConsumerIdThe consumer ID of the client"cps-ncmp"
setTimeoutMsTime in ms to wait for messages on the server before returning10000
setLimitMaximum number of messages that is returned per fetch1000
setFilterA customizable message filter, or null if no filtering is requirednull
setApiKey_usernameThe username of the client applicationnull
setApiSecret_passwordThe password for the usernamenull

The consumer also takes in the following properties:

Setting the Protocol Flag
# This Specifies the request header type used in the request to DMaaP server.
# Valid types:
#   DME2
#   HTTPAAF
#   HTTPAUTH
#   HTTPNOAUTH
# For this POC we use the HTTPNOAUTH, this supports both https and http protocols.

mrConsumer.setProtocolFlag("HTTPNOAUTH");
Setting the Protocol property
# The http protocol to use:
# http
# https

final Properties props = new Properties();
props.setProperty("Protocol", "http");
mrConsumer.setProps(props);

To fetch the following method needs to be called on the consumer object:

Fetch Method Example
mrConsumer.fetch()

The POC used in the demo:

Demo POC code
public static void main(String[] args) throws Exception {
	final Collection<String> hosts = new ArrayList<>();
    hosts.add("message-router.onap:3904");
    final MRConsumerImpl mrConsumer = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
    	.setTopic("AAI-EVENT").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(10000)
        .setLimit(1000).setFilter("").setApiKey_username(null)
        .setApiSecret_password(null).createMRConsumerImpl();
	mrConsumer.setProtocolFlag("HTTPNOAUTH");
    final Properties props = new Properties();
    props.setProperty("Protocol", "http");
    mrConsumer.setProps(props);
    log.info("fetch {}", mrConsumer.fetch());
}
  • No labels