quantranhong1999 commented on code in PR #2028: URL: https://github.com/apache/james-project/pull/2028#discussion_r1503585953
########## event-bus/distributed/src/main/java/org/apache/james/events/KeyRegistrationBinder.java: ########## @@ -19,36 +19,30 @@ package org.apache.james.events; +import io.lettuce.core.api.reactive.RedisSetReactiveCommands; import reactor.core.publisher.Mono; -import reactor.rabbitmq.BindingSpecification; -import reactor.rabbitmq.Sender; -class RegistrationBinder { - private final NamingStrategy namingStrategy; - private final Sender sender; - private final RegistrationQueueName registrationQueue; +class KeyRegistrationBinder { + private final RedisSetReactiveCommands<String, String> redisSetReactiveCommands; + private final RegistrationChannelName registrationChannel; - RegistrationBinder(NamingStrategy namingStrategy, Sender sender, RegistrationQueueName registrationQueue) { - this.namingStrategy = namingStrategy; - this.sender = sender; - this.registrationQueue = registrationQueue; + KeyRegistrationBinder(RedisSetReactiveCommands<String, String> redisSetReactiveCommands, + RegistrationChannelName registrationChannel) { + this.redisSetReactiveCommands = redisSetReactiveCommands; + this.registrationChannel = registrationChannel; } Mono<Void> bind(RegistrationKey key) { - return sender.bind(bindingSpecification(key)) + // Use Redis Set to store 1 registrationKey -> n channel(s) mapping in Redis + RoutingKeyConverter.RoutingKey routingKey = RoutingKeyConverter.RoutingKey.of(key); + return redisSetReactiveCommands.sadd(routingKey.asString(), registrationChannel.asString()) .then(); } Mono<Void> unbind(RegistrationKey key) { - return sender.unbind(bindingSpecification(key)) - .then(); - } - - private BindingSpecification bindingSpecification(RegistrationKey key) { + // delete the registrationKey -> channel mapping in Redis RoutingKeyConverter.RoutingKey routingKey = RoutingKeyConverter.RoutingKey.of(key); - return BindingSpecification.binding() - .exchange(namingStrategy.exchange()) - .queue(registrationQueue.asString()) - .routingKey(routingKey.asString()); + return redisSetReactiveCommands.srem(routingKey.asString(), registrationChannel.asString()) Review Comment: Good question. I do not know the answer yet. But I knew that we need to carefully manage/clean up data in Redis. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org