From 499bc002ae824c4cd5677d7e393381ffe27f9e68 Mon Sep 17 00:00:00 2001 From: PAVEL PALMA Date: Tue, 2 Sep 2025 14:16:30 -0600 Subject: [PATCH] UPDATE 02-sept --- pom.xml | 10 +++++ .../java/com/example/config/RedisConfig.java | 15 -------- .../NotificationExpirationListener.java | 37 ------------------- 3 files changed, 10 insertions(+), 52 deletions(-) delete mode 100644 src/main/java/com/example/service/notification/NotificationExpirationListener.java diff --git a/pom.xml b/pom.xml index b1f49d6..954f683 100644 --- a/pom.xml +++ b/pom.xml @@ -123,6 +123,16 @@ com.google.cloud google-cloud-dlp + + io.netty + netty-codec-http2 + 4.1.124.Final + + + com.google.protobuf + protobuf-java + 3.25.5 + diff --git a/src/main/java/com/example/config/RedisConfig.java b/src/main/java/com/example/config/RedisConfig.java index 63011af..ca28bc6 100644 --- a/src/main/java/com/example/config/RedisConfig.java +++ b/src/main/java/com/example/config/RedisConfig.java @@ -15,13 +15,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory; import org.springframework.data.redis.core.ReactiveRedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.listener.RedisMessageListenerContainer; -import org.springframework.data.redis.listener.PatternTopic; import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.StringRedisSerializer; -import com.example.service.notification.NotificationExpirationListener; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.beans.factory.annotation.Autowired; /** * Spring configuration class for setting up Reactive Redis(Memorystore in GCP) @@ -79,14 +74,4 @@ public ReactiveRedisTemplate reactiveNotificatio .build(); return new ReactiveRedisTemplate<>(factory, context); } - -@Bean -public RedisMessageListenerContainer keyExpirationListenerContainer( - @Autowired RedisConnectionFactory connectionFactory, - @Autowired NotificationExpirationListener notificationExpirationListener) { - RedisMessageListenerContainer listenerContainer = new RedisMessageListenerContainer(); - listenerContainer.setConnectionFactory(connectionFactory); - listenerContainer.addMessageListener(notificationExpirationListener, new PatternTopic("__keyevent@*__:expired")); - return listenerContainer; -} } \ No newline at end of file diff --git a/src/main/java/com/example/service/notification/NotificationExpirationListener.java b/src/main/java/com/example/service/notification/NotificationExpirationListener.java deleted file mode 100644 index 5a5f4d2..0000000 --- a/src/main/java/com/example/service/notification/NotificationExpirationListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose. - * Your use of it is subject to your agreement with Google. - */ - -package com.example.service.notification; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.stereotype.Service; - -@Service -public class NotificationExpirationListener implements MessageListener { - - private static final Logger logger = LoggerFactory.getLogger(NotificationExpirationListener.class); - private final FirestoreNotificationService firestoreNotificationService; - private static final String NOTIFICATION_KEY_PREFIX = "notification:"; - - public NotificationExpirationListener(FirestoreNotificationService firestoreNotificationService) { - this.firestoreNotificationService = firestoreNotificationService; - } - - @Override - public void onMessage(Message message, byte[] pattern) { - String expiredKey = new String(message.getBody()); - logger.info("Expired key: " + expiredKey); - if (expiredKey.startsWith(NOTIFICATION_KEY_PREFIX)) { - String sessionId = expiredKey.substring(NOTIFICATION_KEY_PREFIX.length()); - firestoreNotificationService.updateNotificationStatus(sessionId, "inactive") - .doOnSuccess(v -> logger.info("Notification status updated to inactive for session: " + sessionId)) - .doOnError(e -> logger.error("Error updating notification status for session: " + sessionId, e)) - .subscribe(); - } - } -}