Skip to content

Commit

Permalink
Merge pull request #10 from Valensas/feature/remove-feign-interceptor
Browse files Browse the repository at this point in the history
remove header propagation implementations
  • Loading branch information
yavuzselimkaraman authored Aug 14, 2024
2 parents 58aebeb + 869050f commit 99c4d97
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 228 deletions.
10 changes: 3 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "com.valensas"
version = "0.2.2"
version = "0.3.0"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand All @@ -25,11 +25,6 @@ tasks.getByName<Jar>("jar") {
}

dependencies {

compileOnly("org.springframework.cloud:spring-cloud-starter-openfeign:4.1.1")

compileOnly("org.springframework.boot:spring-boot-starter-web")

// Autoconfiguration
implementation("org.springframework.boot:spring-boot-autoconfigure")

Expand Down Expand Up @@ -108,4 +103,5 @@ centralPortal {
}
}
}
}
}

22 changes: 0 additions & 22 deletions src/main/kotlin/com/valensas/kafka/config/FeignConfiguration.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package com.valensas.kafka.config

import com.fasterxml.jackson.databind.ObjectMapper
import com.valensas.kafka.deserializer.KafkaModelDeserializer
import com.valensas.kafka.interceptor.KafkaHeaderPropagationConsumerInterceptor
import com.valensas.kafka.interceptor.KafkaHeaderPropagationProducerInterceptor
import com.valensas.kafka.properties.HeaderPropagationProperties
import io.github.springwolf.core.configuration.properties.SpringwolfConfigProperties
import org.apache.kafka.clients.producer.ProducerConfig
import org.reflections.Reflections
Expand Down Expand Up @@ -48,12 +45,13 @@ class KafkaAutoConfiguration {

@Bean
fun producerFactory(
interceptors: List<ProducerInterceptorClassHolder>,
objectMapper: ObjectMapper,
properties: KafkaProperties
): ProducerFactory<String, *> {
val producerProperties = properties.buildProducerProperties(null)
producerProperties[ProducerConfig.INTERCEPTOR_CLASSES_CONFIG] =
KafkaHeaderPropagationProducerInterceptor::class.java.getName()
interceptors.joinToString { it.producerInterceptorClass.getName() }
val factory = DefaultKafkaProducerFactory<String, Any>(producerProperties)
factory.valueSerializer = JsonSerializer(objectMapper)
return factory
Expand All @@ -62,14 +60,15 @@ class KafkaAutoConfiguration {
@Bean
@ConditionalOnProperty("spring.kafka.consumer.enabled", havingValue = "true")
fun consumerFactory(
interceptors: List<ConsumerInterceptorClassHolder>,
deserializer: KafkaModelDeserializer,
properties: KafkaProperties,
headerPropagationProperties: HeaderPropagationProperties
applicationContext: ApplicationContext
): ConsumerFactory<*, *> {
val consumerProperties = properties.buildConsumerProperties(null)
consumerProperties[ProducerConfig.INTERCEPTOR_CLASSES_CONFIG] =
KafkaHeaderPropagationConsumerInterceptor::class.java.getName()
consumerProperties["headerPropagationProperties"] = headerPropagationProperties
interceptors.joinToString { it.consumerInterceptorClass.getName() }
consumerProperties["applicationContext"] = applicationContext
val factory = DefaultKafkaConsumerFactory<Any, Any>(consumerProperties)
factory.setValueDeserializer(deserializer)
return factory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.valensas.kafka.config

import org.apache.kafka.clients.consumer.ConsumerInterceptor
import org.apache.kafka.clients.producer.ProducerInterceptor

data class ProducerInterceptorClassHolder(
val producerInterceptorClass: Class<out ProducerInterceptor<*, *>>
)

data class ConsumerInterceptorClassHolder(
val consumerInterceptorClass: Class<out ConsumerInterceptor<*, *>>
)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
com.valensas.kafka.config.KafkaAutoConfiguration
com.valensas.kafka.config.HeaderPropagationAutoConfiguration
com.valensas.kafka.config.KafkaAutoConfiguration

0 comments on commit 99c4d97

Please sign in to comment.