Merge "Created media folders for ResourceDictionary"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / selfservice-api / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / selfservice / api / messaginglib / ProducerConfiguration.kt
1 /*
2  * Copyright © 2019 Bell Canada
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.messaginglib
17
18 import org.apache.kafka.clients.producer.ProducerConfig
19 import org.apache.kafka.common.serialization.StringSerializer
20 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
21 import org.springframework.beans.factory.annotation.Value
22 import org.springframework.context.annotation.Bean
23 import org.springframework.context.annotation.Configuration
24 import org.springframework.kafka.annotation.EnableKafka
25 import org.springframework.kafka.core.DefaultKafkaProducerFactory
26 import org.springframework.kafka.core.KafkaTemplate
27 import org.springframework.kafka.core.ProducerFactory
28 import org.springframework.kafka.support.serializer.JsonSerializer
29
30 @Configuration
31 open class ProducerConfiguration {
32
33     @Value("\${blueprintsprocessor.messageclient.self-service-api.bootstrapServers}")
34     lateinit var bootstrapServers: String
35
36     open fun kpf(): ProducerFactory<String, ExecutionServiceInput> {
37         val configs = HashMap<String, Any>()
38         configs[ProducerConfig.BOOTSTRAP_SERVERS_CONFIG] = bootstrapServers
39         configs[ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java
40         configs[ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG] = JsonSerializer::class.java
41         return DefaultKafkaProducerFactory(configs)
42     }
43
44     @Bean
45     open fun kt(): KafkaTemplate<String, ExecutionServiceInput> {
46         return KafkaTemplate<String, ExecutionServiceInput>(kpf())
47     }
48 }