当前位置: 首页>>代码示例>>Java>>正文


Java Message.getChannel方法代码示例

本文整理汇总了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);
}
 
开发者ID:irfen,项目名称:redis-example,代码行数:8,代码来源:RedisSubTest.java

示例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);
}
 
开发者ID:izhangzhihao,项目名称:Shiro-Session-Redis,代码行数:11,代码来源:ShiroSessionService.java

示例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()));
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:34,代码来源:RedisTimerListener.java

示例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);
		}
	}
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:50,代码来源:RedisOperationsSessionRepository.java


注:本文中的org.springframework.data.redis.connection.Message.getChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。