ltd.fdsa.redis.event.RedisEventService Maven / Gradle / Ivy
package ltd.fdsa.redis.event;
import lombok.extern.slf4j.Slf4j;
import ltd.fdsa.core.event.RemoteEventPublisher;
import ltd.fdsa.core.event.RemotingEvent;
import ltd.fdsa.redis.properties.RedisConfigProperties;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@Slf4j
public class RedisEventService implements RemoteEventPublisher {
private final RedisConfigProperties properties;
private final RedisTemplate eventRedisTemplate;
public RedisEventService(RedisConfigProperties properties, RedisConnectionFactory connectionFactory) {
this.properties = properties;
this.eventRedisTemplate = new RedisTemplate();
this.eventRedisTemplate.setConnectionFactory(connectionFactory);
}
@Override
public void send(RemotingEvent event) {
this.eventRedisTemplate.convertAndSend(this.properties.getEventWatch().getKeyPrefix(), event);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy