org.springframework.data.redis.connection.RedisConnection.subscribe()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.springframework.data.redis.connection.RedisConnection.subscribe方法的一些代码示例,展示了RedisConnection.subscribe的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisConnection.subscribe方法的具体详情如下:
包路径:org.springframework.data.redis.connection.RedisConnection
类名称:RedisConnection
方法名:subscribe

RedisConnection.subscribe介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public void subscribe(MessageListener listener, byte[]... channels) {
  delegate.subscribe(listener, channels);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public void subscribe(MessageListener listener, String... channels) {
  delegate.subscribe(listener, serializeMulti(channels));
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Performs a potentially asynchronous registration of a subscription.
 *
 * @return #SubscriptionPresentCondition that can serve as a handle to check whether the subscription is ready.
 */
private SubscriptionPresentCondition eventuallyPerformSubscription() {
  SubscriptionPresentCondition condition = null;
  if (channelMapping.isEmpty()) {
    condition = new PatternSubscriptionPresentCondition();
    connection.pSubscribe(new DispatchMessageListener(), unwrap(patternMapping.keySet()));
  } else {
    if (patternMapping.isEmpty()) {
      condition = new SubscriptionPresentCondition();
    } else {
      // schedule the rest of the subscription
      subscriptionExecutor.execute(new PatternSubscriptionTask());
      condition = new PatternSubscriptionPresentCondition();
    }
    connection.subscribe(new DispatchMessageListener(), unwrap(channelMapping.keySet()));
  }
  return condition;
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public void subscribe(MessageListener listener, byte[]... channels) {
  delegate.subscribe(listener, channels);
}

代码示例来源:origin: 1991wangliang/tx-lcn

@Override
public void subscribe(MessageListener listener, byte[]... channels) {
  redisConnection.subscribe(listener, channels);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public void subscribe(MessageListener listener, byte[]... channels) {
  delegate.subscribe(listener, channels);
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public void subscribe(MessageListener listener, String... channels) {
  delegate.subscribe(listener, serializeMulti(channels));
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public void subscribe(MessageListener listener, String... channels) {
  delegate.subscribe(listener, serializeMulti(channels));
}

代码示例来源:origin: gudaoxuri/dew

@Override
protected void doSubscribe(String topic, Consumer<String> consumer) {
  new Thread(() -> redisTemplate.execute((RedisCallback<Void>) connection -> {
    connection.subscribe((message, pattern) ->
            consumer.accept(new String(message.getBody(), StandardCharsets.UTF_8))
        , topic.getBytes());
    return null;
  })).start();
}

代码示例来源:origin: aillamsun/devX

@Override
public void subscribe(String topic, Consumer<String> consumer) {
  new Thread(() -> redisTemplate.execute((RedisCallback<Void>) connection -> {
    connection.subscribe((message, pattern) -> {
      try {
        String msg = new String(message.getBody(), "UTF-8");
        logger.trace("[MQ] subscribe {}:{}", topic, msg);
        consumer.accept(msg);
      } catch (Exception e) {
        logger.error("Redis Subscribe error.", e);
      }
    }, topic.getBytes());
    return null;
  })).start();
}

代码示例来源:origin: com.ecfront.dew/cluster-spi-redis

@Override
public void subscribe(String topic, Consumer<String> consumer) {
  RedisConnection connection = null;
  try {
    connection = redisTemplate.getConnectionFactory().getConnection();
    connection.subscribe((message, pattern) -> {
      try {
        String msg = new String(message.getBody(), "UTF-8");
        logger.trace("[MQ] subscribe {}:{}", topic, msg);
        consumer.accept(msg);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }, topic.getBytes());
  } finally {
    if (connection != null && !connection.isClosed()) {
      connection.close();
    }
  }
}

代码示例来源:origin: org.springframework.data/spring-data-redis

/**
 * Performs a potentially asynchronous registration of a subscription.
 *
 * @return #SubscriptionPresentCondition that can serve as a handle to check whether the subscription is ready.
 */
private SubscriptionPresentCondition eventuallyPerformSubscription() {
  SubscriptionPresentCondition condition = null;
  if (channelMapping.isEmpty()) {
    condition = new PatternSubscriptionPresentCondition();
    connection.pSubscribe(new DispatchMessageListener(), unwrap(patternMapping.keySet()));
  } else {
    if (patternMapping.isEmpty()) {
      condition = new SubscriptionPresentCondition();
    } else {
      // schedule the rest of the subscription
      subscriptionExecutor.execute(new PatternSubscriptionTask());
      condition = new PatternSubscriptionPresentCondition();
    }
    connection.subscribe(new DispatchMessageListener(), unwrap(channelMapping.keySet()));
  }
  return condition;
}

代码示例来源:origin: choerodon/choerodon-starters

/**
 * Performs a potentially asynchronous registration of a subscription.
 *
 * @return #SubscriptionPresentCondition that can serve as a handle to check whether the subscription is ready.
 */
private ClRedisContainer.SubscriptionTask.SubscriptionPresentCondition eventuallyPerformSubscription() {
  ClRedisContainer.SubscriptionTask.SubscriptionPresentCondition condition = null;
  if (channelMapping.isEmpty()) {
    condition = new ClRedisContainer.SubscriptionTask.PatternSubscriptionPresentCondition();
    connection.pSubscribe(new ClRedisContainer.DispatchMessageListener(), unwrap(patternMapping.keySet()));
  } else {
    if (patternMapping.isEmpty()) {
      condition = new ClRedisContainer.SubscriptionTask.SubscriptionPresentCondition();
    } else {
      // schedule the rest of the subscription
      subscriptionExecutor.execute(new ClRedisContainer.SubscriptionTask.PatternSubscriptionTask());
      condition = new ClRedisContainer.SubscriptionTask.PatternSubscriptionPresentCondition();
    }
    connection.subscribe(new ClRedisContainer.DispatchMessageListener(), unwrap(channelMapping.keySet()));
  }
  return condition;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Performs a potentially asynchronous registration of a subscription.
 *
 * @return #SubscriptionPresentCondition that can serve as a handle to check whether the subscription is ready.
 */
private SubscriptionPresentCondition eventuallyPerformSubscription() {
  SubscriptionPresentCondition condition = null;
  if (channelMapping.isEmpty()) {
    condition = new PatternSubscriptionPresentCondition();
    connection.pSubscribe(new DispatchMessageListener(), unwrap(patternMapping.keySet()));
  } else {
    if (patternMapping.isEmpty()) {
      condition = new SubscriptionPresentCondition();
    } else {
      // schedule the rest of the subscription
      subscriptionExecutor.execute(new PatternSubscriptionTask());
      condition = new PatternSubscriptionPresentCondition();
    }
    connection.subscribe(new DispatchMessageListener(), unwrap(channelMapping.keySet()));
  }
  return condition;
}

相关文章

微信公众号

最新文章

更多

RedisConnection类方法