Package org.springframework.data.redis.listener.adapter

Examples of org.springframework.data.redis.listener.adapter.MessageListenerAdapter


    this.redisTemplate = template;
    return template;
  }

  private void setupMessageListener(CountDownLatch latch, String topic) throws InterruptedException {
    MessageListenerAdapter listener = new MessageListenerAdapter();
    listener.setDelegate(new Listener(latch));
    listener.afterPropertiesSet();

    this.container = new RedisMessageListenerContainer();
    container.setConnectionFactory(this.redisAvailableRule.getResource());
    container.afterPropertiesSet();
    container.addMessageListener(listener, Collections.<Topic> singletonList(new ChannelTopic(topic)));
View Full Code Here


    assertEquals(0, latch.getCount());
    container.stop();
  }

  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)));
View Full Code Here

    // container stop
    for (int i = 0; i < 8; i++) {
      RedisMessageListenerContainer container = new RedisMessageListenerContainer();
      container.setConnectionFactory(connectionFactory);
      container.setBeanName("container" + i);
      container.addMessageListener(new MessageListenerAdapter(handler), Arrays.asList(new ChannelTopic(CHANNEL)));
      container.setTaskExecutor(new SyncTaskExecutor());
      container.setSubscriptionExecutor(new SimpleAsyncTaskExecutor());
      container.afterPropertiesSet();
      container.start();
View Full Code Here

  }

  @Test
  public void testRemoveLastListener() throws Exception {
    // Grab all 8 connections from the pool
    MessageListener listener = new MessageListenerAdapter(handler);
    for (int i = 0; i < 8; i++) {
      RedisMessageListenerContainer container = new RedisMessageListenerContainer();
      container.setConnectionFactory(connectionFactory);
      container.setBeanName("container" + i);
      container.addMessageListener(listener, Arrays.asList(new ChannelTopic(CHANNEL)));
View Full Code Here

  }

  @Test
  public void testStopListening() throws InterruptedException {
    // Grab all 8 connections from the pool.
    MessageListener listener = new MessageListenerAdapter(handler);
    for (int i = 0; i < 8; i++) {
      RedisMessageListenerContainer container = new RedisMessageListenerContainer();
      container.setConnectionFactory(connectionFactory);
      container.setBeanName("container" + i);
      container.addMessageListener(listener, Arrays.asList(new ChannelTopic(CHANNEL)));
View Full Code Here

    final String PATTERN = "p*";
    final String ANOTHER_CHANNEL = "pubsub::test::extra";

    BlockingDeque<String> bag2 = new LinkedBlockingDeque<String>(99);
    MessageListenerAdapter anotherListener = new MessageListenerAdapter(new MessageHandler("handler2", bag2));
    anotherListener.setSerializer(template.getValueSerializer());
    anotherListener.afterPropertiesSet();

    // remove adapter from all channels
    container.addMessageListener(anotherListener, new PatternTopic(PATTERN));
    container.removeMessageListener(adapter);

View Full Code Here

TOP

Related Classes of org.springframework.data.redis.listener.adapter.MessageListenerAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.