jcasbin / casbin-spring-boot-starter

Spring Boot 2.x & 3.x Starter for Casbin, see example at: https://github.com/jcasbin/casbin-spring-boot-example
https://mvnrepository.com/artifact/org.casbin/casbin-spring-boot-starter
Apache License 2.0
196 stars 70 forks source link

The built-in Watcher doesn't support customized Redis channel, how to use the official Java's Redis-Watcher? #54

Closed bilinxing closed 2 years ago

bilinxing commented 2 years ago

How to import java redis watcher: https://github.com/jcasbin/redis-watcher

casbin-bot commented 2 years ago

@tangyang9464 @seriouszyx @elfisworking @fangzhengjin

hsluoyz commented 2 years ago

@bilinxing plz use English, thanks!

hsluoyz commented 2 years ago

@fangzhengjin any comments?

fabian4 commented 2 years ago

There might be an alternative way to get what you want.

you can replace the original MessageListenerAdapter with your own

@Configuration
public class jCasbinConfiguration {

    public final static String CASBIN_POLICY_TOPIC = "YOUR_CUSTOMER_TOPIC";

    public jCasbinConfiguration(
            RedisMessageListenerContainer redisMessageListenerContainer,
            MessageListenerAdapter listenerAdapter
            ) {

        redisMessageListenerContainer.removeMessageListener(listenerAdapter);
        redisMessageListenerContainer.addMessageListener(listenerAdapter, new ChannelTopic(CASBIN_POLICY_TOPIC));
    }
}
hsluoyz commented 2 years ago

@bilinxing