...
-> DMaaP (Kafka/Zookeeper backend)
-> Kafka (Kafka/Strimzi backend)
-> UEB
-> NOOP
-> Http Servers
-> Http Clients
What changes are needed in Policy framework application properties?
Following are the properties for topicSources and topicSinks used across all the applications in policy-framework to communicate with certain endpoints.
...
Changing topicCommInfrastructure: kafka in application propertiesshould be able to allow messaging to be carried over Kafka.
Additional optional kafka properties needed in application properties of any spring-boot application
Code Block | ||
---|---|---|
| ||
spring: kafka: template: default-topic: POLICY-PDP-PAP consumer: bootstrap-servers: localhost:9092,localhost:9093,localhost:9094 key-deserializer: org.apache.kafka.common.serialization.IntegerDeserializer value-deserializer: org.apache.kafka.common.serialization.StringDeserializer group-id: pap-group producer: bootstrap-servers: localhost:9092,localhost:9093,localhost:9094 key-serializer: org.apache.kafka.common.serialization.IntegerSerializer value-serializer: org.apache.kafka.common.serialization.StringSerializer |
...
How to run Kafka?
Kafka dependencies to be added in policy-endpoints/pom.xml of policy/common repoInstall any latest stable version of Kafka, edit the server.properties as desired and run
Code Block | ||
---|---|---|
| ||
~/ONAP/kafka_2.12-3.1.0# ls
bin config data libs LICENSE licenses logs NOTICE site-docs
~/ONAP/kafka_2.12-3.1.0# bin/kafka-server-start.sh config/server.properties |
POLICY-ENDPOINTS
Kafka dependencies to be added in policy-endpoints/pom.xml of policy/common repo
bin/kafka-server-start.sh config/server.properties |
What changes are needed in POLICY-ENDPOINTS codebase?
Kafka dependencies to be added in policy-endpoints/pom.xml of policy/common repo
Code Block | ||
---|---|---|
| ||
Code Block | ||
| ||
<dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> <version>2.7.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot<kafka</groupId> <artifactId>spring-boot-starter-test<kafka</artifactId> <scope>test</scope><version>2.7.2</version> </dependency> |
New communciation communication infrastructure type to be introduced in policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java
...
Code Block | ||
---|---|---|
| ||
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicEndpoint.java policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactories.java policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactory.java policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSink.java policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactory.java policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSource.java policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactory.java |
Why Spring Kafka?
Spring Kafka brings the simple Spring template programming model with a KafkaTemplate and Message-driven POJOs via @KafkaListener annotation.
...
kafkaTemplate.send(<topic>, <message>);
...
How to start a sample policy participant application with Kafka?
Code Block | ||
---|---|---|
| ||
@SpringBootApplication @ComponentScan({ "org.onap.policy.clamp.controlloop.participant.policy", "org.onap.policy.clamp.controlloop.participant.intermediary", "org.onap.policy.common.endpoints.event.comm.kafka"}) @ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.policy.main.parameters") public class PolicyParticipantApplication { public static void main(String[] args) { SpringApplication.run(PolicyParticipantApplication.class, args); } } |
...
- policy-common is not converted to Springboot.
- Policy-endpoint classes are being converted to Springboot components to acheive achieve reuse.
Summary
- Policy-framework applications and current communication infrastructure will-not experience any code changes
- Include Kafka properties and change topicCommInfrastructure to Kafka, if communication if desired over Kafka then current Dmaap communication
- Run Kafka with needed server properties instead of Dmaap
- This endpoint will be a managed end-point and lifecycle management will be taken care by repsective respective changes in policy-common repo.
...