• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChannelTopic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.data.redis.listener.ChannelTopic的典型用法代码示例。如果您正苦于以下问题:Java ChannelTopic类的具体用法?Java ChannelTopic怎么用?Java ChannelTopic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChannelTopic类属于org.springframework.data.redis.listener包,在下文中一共展示了ChannelTopic类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: subscribe

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
public void subscribe(ChannelHandlerContext context, String channel, String subId) {

        // dont want to trust the client to guive me a unique session id
        // so, going to add some salt to the session id and try to mitigate the chances for the client miss behaving
        String listenerId = Listener.getListenerUniqueId(context, subId);

        if (!subscriptions.containsKey(listenerId)) {
            Topic topic = new ChannelTopic(properties.getRedisChannelPrefix() + channel);
            LOGGER.debug("Subscribing client address={} subscription={} mapping channel={} onto topic={}",
                context.channel().remoteAddress(), subId, channel, topic);

            PerSubscriptionListenerAdapter listener = new PerSubscriptionListenerAdapter(context, subId, listenerId);
            redisMessageListenerContainer.addMessageListener(listener, topic);
            subscriptions.put(listenerId, listener);
        } else {

            LOGGER.warn(
                "Listner [{}] already exists. Maybe clients are not sending unique session ids.",
                listenerId);
        }
    }
 
开发者ID:itzg,项目名称:redis-stomp-relay,代码行数:22,代码来源:SubscriptionManagement.java


示例2: topic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Bean
ChannelTopic topic() {
    return new ChannelTopic("pubsub:queue");
}
 
开发者ID:michaelcgood,项目名称:spring-data-redis-example,代码行数:5,代码来源:RedisConfig.java


示例3: setupListener

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
private void setupListener(RedisSerializer<?> listenerSerializer) throws InterruptedException {
	MessageListenerAdapter listener = new MessageListenerAdapter();
	listener.setDelegate(new Listener(latch));
	listener.setSerializer(listenerSerializer);
	listener.afterPropertiesSet();

	this.container = new RedisMessageListenerContainer();
	container.setConnectionFactory(connectionFactory);
	container.afterPropertiesSet();
	container.addMessageListener(listener, Collections.<Topic> singletonList(new ChannelTopic(TOPIC)));
	container.start();
	Thread.sleep(1000);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-redis,代码行数:14,代码来源:RedisPublishingMessageHandlerTests.java


示例4: toTopics

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
private Collection<Topic> toTopics(String channels) {
    String[] channelsArrays = channels.split(",");
    List<Topic> topics = new ArrayList<>();
    for (String channel : channelsArrays) {
        String name = channel.trim();
        if (Command.PSUBSCRIBE.equals(redisConfiguration.getCommand())) {
            topics.add(new PatternTopic(name));
        } else if (Command.SUBSCRIBE.equals(redisConfiguration.getCommand())) {
            topics.add(new ChannelTopic(name));
        } else {
            throw new IllegalArgumentException("Unsupported Command " + redisConfiguration.getCommand());
        }
    }
    return topics;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:RedisConsumer.java


示例5: registerConsumerForTwoChannelTopics

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Test
public void registerConsumerForTwoChannelTopics() throws Exception {
    ArgumentCaptor<Collection> collectionCaptor = ArgumentCaptor.forClass(Collection.class);
    verify(listenerContainer).addMessageListener(any(MessageListener.class), collectionCaptor.capture());

    Collection<ChannelTopic> topics = collectionCaptor.getValue();
    Iterator<ChannelTopic> topicIterator = topics.iterator();

    Topic firstTopic = topicIterator.next();
    Topic twoTopic = topicIterator.next();

    assertEquals("one", firstTopic.getTopic());
    assertEquals("two", twoTopic.getTopic());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:RedisConsumerTest.java


示例6: MessagePublisherImpl

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
public MessagePublisherImpl(final RedisTemplate<String, Object> redisTemplate, final ChannelTopic topic) {
    this.redisTemplate = redisTemplate;
    this.topic = topic;
}
 
开发者ID:michaelcgood,项目名称:spring-data-redis-example,代码行数:5,代码来源:MessagePublisherImpl.java


示例7: topic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Bean
ChannelTopic topic() {
    return new ChannelTopic(topic);
}
 
开发者ID:V-I-C-T-O-R,项目名称:DataM,代码行数:5,代码来源:RedisConfig.java


示例8: RedisInfoPublisher

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
public RedisInfoPublisher(StringRedisTemplate redisTemplate, ChannelTopic topic) {
    this.redisTemplate = redisTemplate;
    this.topic = topic;
}
 
开发者ID:V-I-C-T-O-R,项目名称:DataM,代码行数:5,代码来源:RedisInfoPublisher.java


示例9: getTopic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Override
public ChannelTopic getTopic(String channel) {
   return new ChannelTopic(keyString(CHANNEL, channel));
}
 
开发者ID:shopping24,项目名称:redjob,代码行数:5,代码来源:ChannelDaoImpl.java


示例10: gameTopic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Bean
public Topic gameTopic() {
    return new ChannelTopic("pubsub:game");
}
 
开发者ID:Turbots,项目名称:SpringOne2016,代码行数:5,代码来源:RedisConfiguration.java


示例11: chatTopic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Bean
public Topic chatTopic() {
    return new ChannelTopic("pubsub:chat");
}
 
开发者ID:Turbots,项目名称:SpringOne2016,代码行数:5,代码来源:RedisConfiguration.java


示例12: createRoom

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
/**
 * 채팅방 생성 로직 
 */
public void createRoom(CreateRoom req, String myId, ChannelHandlerContext ctx){
	Channel ch = ctx.channel();
	JSONObject result = null;
	try{
		//방정보 생성
		String roomId = indexDAO.increaseRoomIndex();	//방 인덱스
		List<String> idList = req.getIdList();
		if(idList==null)
			throw new Exception("초대할 친구 리스트가 비었습니다.");

		//방접속 정보 저장
		messageDAO.saveRoomList(myId, roomId);
		messageDAO.saveRoomUser(roomId, myId);
		MessageListener listener = new MessageListenerImpl(myId, roomId, failDAO);
		redisContainer.addMessageListener(listener, new ChannelTopic(roomId));	//리스너 자원 관리
		idChannelListenerMap.get(myId).put(roomId, listener);

		for(String id : idList){
			Member member = new Member();
			member.setId(id); 
			//존재하는 사용자 일 경우에만
			if(memberService.isExistsMember(member) == true && id.equals(myId) == false ){
				messageDAO.saveRoomList(id, roomId);
				messageDAO.saveRoomUser(roomId, id);
				TokenListItem item = memberService.getTokenListItem(id);
				String friendToken = item.getToken();
				MessageListener listenerForSubscriber = new MessageListenerImpl(id, roomId, failDAO);
				redisContainer.addMessageListener(listenerForSubscriber, new ChannelTopic(roomId));	
				idChannelListenerMap.get(id).put(roomId, listenerForSubscriber);
			}
		}

		//초기 메세지 저장/전송 (publish)

		String messageIndex = indexDAO.increaseMessageIndex(roomId);

		Packet packet = new Packet();
		packet.setFromId(myId);
		packet.setContent(myId+"님의 채팅방에 초대 되었습니다.");
		packet.setRoomId(roomId);
		packet.setTimestamp(System.currentTimeMillis() / 1000);
		packet.setMessageIndex(messageIndex);

		messageDAO.saveMessage(roomId, packet);	//Redis 저장
		messageDAO.sendMessage(roomId, packet);	//메세지 전송 (publish)

		//응답
		result = new JSONObject();
		result.put("result", true);
		result.put("type", Protocol.createRoom.name());
		JSONObject body = new JSONObject();
		body.put("roomId", roomId);
		result.put("response", body);

	}catch(Exception e){
		e.printStackTrace();

		//응답
		result = new JSONObject();
		try {
			result.put("result", false);
			result.put("type", Protocol.createRoom.name());
		} catch (JSONException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}finally{
		ch.writeAndFlush(result.toString());
	}
}
 
开发者ID:qwefgh90,项目名称:ChangTalk,代码行数:74,代码来源:JsonHandler.java


示例13: sampleTopic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Bean
ChannelTopic sampleTopic() {
	return new ChannelTopic( "CHANGIM" );
}
 
开发者ID:qwefgh90,项目名称:ChangTalk,代码行数:5,代码来源:Application.java


示例14: createTopic

import org.springframework.data.redis.listener.ChannelTopic; //导入依赖的package包/类
@Bean
ChannelTopic createTopic()
{
    return new ChannelTopic("pubsub:channel");
}
 
开发者ID:omanand,项目名称:spring-data-redis-demo,代码行数:6,代码来源:AppConfiguration.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Operator类代码示例发布时间:2022-05-21
下一篇:
Java StringVector类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap