本文整理汇总了Java中org.springframework.data.redis.connection.Message.getChannel方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getChannel方法的具体用法?Java Message.getChannel怎么用?Java Message.getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.redis.connection.Message
的用法示例。
在下文中一共展示了Message.getChannel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import org.springframework.data.redis.connection.Message; //导入方法依赖的package包/类
public void onMessage(Message message, byte[] pattern) {
byte[] body = message.getBody();
byte[] channel = message.getChannel();
String content = redisTemplate.getStringSerializer().deserialize(body);
String publisher = redisTemplate.getStringSerializer().deserialize(channel);
System.out.println(publisher + ": " + content);
}
示例2: onMessage
import org.springframework.data.redis.connection.Message; //导入方法依赖的package包/类
/**
* 收到缓存过期消息时清除EhCache中的Session缓存
*/
@Override
public void onMessage(final @NotNull Message message, byte[] bytes) {
ShiroSessionMessage shiroSessionMessage =
new ShiroSessionMessage(message.getChannel(), message.getBody());
log.debug("channel {} , message {} ", shiroSessionMessage.getChannel(), shiroSessionMessage.msgBody);
sessionDao.unCache(shiroSessionMessage.msgBody.sessionId);
}
示例3: onMessage
import org.springframework.data.redis.connection.Message; //导入方法依赖的package包/类
@Override
public void onMessage(Message message, byte[] pattern) {
byte[] messageChannel = message.getChannel();
byte[] messageBody = message.getBody();
if (messageChannel == null || messageBody == null) {
return;
}
String channel = new String(messageChannel);
if (!channel.contains(REDIS_KEY_WORD)) {
return;
}
String body = new String(messageBody);
if (!body.startsWith(REDIS_KEY_PREFIX)) {
return;
}
String[] temp = StringUtils.split(body, REDIS_KEY_SEPARATOR);
String type = temp[1], key = temp[2];
RedisEventHandler handler = RedisEventUtils.getRedisEventHandler(type);
Serializable id = handler.resolveKey(key);
if (id == null) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Publishing Event for order " + id);
}
publishEvent(new RedisEvent(this, id, handler.getEventType()));
}
示例4: onMessage
import org.springframework.data.redis.connection.Message; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void onMessage(Message message, byte[] pattern) {
byte[] messageChannel = message.getChannel();
byte[] messageBody = message.getBody();
String channel = new String(messageChannel);
if (channel.startsWith(getSessionCreatedChannelPrefix())) {
// TODO: is this thread safe?
Map<Object, Object> loaded = (Map<Object, Object>) this.defaultSerializer
.deserialize(message.getBody());
handleCreated(loaded, channel);
return;
}
String body = new String(messageBody);
if (!body.startsWith(getExpiredKeyPrefix())) {
return;
}
boolean isDeleted = channel.endsWith(":del");
if (isDeleted || channel.endsWith(":expired")) {
int beginIndex = body.lastIndexOf(":") + 1;
int endIndex = body.length();
String sessionId = body.substring(beginIndex, endIndex);
RedisSession session = getSession(sessionId, true);
if (session == null) {
logger.warn("Unable to publish SessionDestroyedEvent for session "
+ sessionId);
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Publishing SessionDestroyedEvent for session " + sessionId);
}
cleanupPrincipalIndex(session);
if (isDeleted) {
handleDeleted(session);
}
else {
handleExpired(session);
}
}
}