diff --git a/noti-service/src/main/java/com/waither/notiservice/config/KafkaConsumerConfig.java b/noti-service/src/main/java/com/waither/notiservice/config/KafkaConsumerConfig.java index 24d01533..ac9b5e18 100644 --- a/noti-service/src/main/java/com/waither/notiservice/config/KafkaConsumerConfig.java +++ b/noti-service/src/main/java/com/waither/notiservice/config/KafkaConsumerConfig.java @@ -90,7 +90,7 @@ public ConcurrentKafkaListenerContainerFactory u private ConsumerFactory userMedianConsumerFactory() { Map props = dtoSettings(); - return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new JsonDeserializer<>(KafkaDto.UserMedianDto.class)); + return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), createJsonDeserializer(KafkaDto.UserMedianDto.class)); } @@ -106,7 +106,7 @@ public ConcurrentKafkaListenerContainerFactory private ConsumerFactory userSettingsConsumerFactory() { Map props = dtoSettings(); - return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new JsonDeserializer<>(KafkaDto.UserSettingsDto.class)); + return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), createJsonDeserializer(KafkaDto.UserSettingsDto.class)); } @@ -122,7 +122,7 @@ public ConcurrentKafkaListenerContainerFactory private ConsumerFactory initialDataConsumerFactory() { Map props = dtoSettings(); - return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new JsonDeserializer<>(KafkaDto.InitialDataDto.class)); + return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), createJsonDeserializer(KafkaDto.InitialDataDto.class)); } @Bean("weatherKafkaListenerContainerFactory") @@ -137,10 +137,13 @@ public ConcurrentKafkaListenerContainerFactory weat private ConsumerFactory weatherConsumerFactory() { Map props = dtoSettings(); - return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new JsonDeserializer<>(KafkaDto.WeatherDto.class)); + return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), createJsonDeserializer(KafkaDto.WeatherDto.class)); } - - + private JsonDeserializer createJsonDeserializer(Class valueType) { + JsonDeserializer jsonDeserializer = new JsonDeserializer<>(valueType); + jsonDeserializer.addTrustedPackages("com.waither.*"); + return jsonDeserializer; + } }