当前位置: 首页 > 知识库问答 >
问题:

Redis莴苣发布

魏凡
2023-03-14

我正在开发JDK 1.8,但我不知道为什么“发布”不起作用。Redis“set”命令正在处理数据。

<dependency>
    <groupId>io.lettuce</groupId>
    <artifactId>lettuce-core</artifactId>
    <version>5.0.1.RELEASE</version>
</dependency> 

代码段:

RedisClient redisClient = RedisClient.create(redisURI);
connection = redisClient.connect();
String l_message = l_eventObject.toString();
connection.sync().publish(l_namespace, l_message);
connection.flushCommands(); // added this to see if this works

从日志调试输出:

01:25:44.826 [Thread-3] DEBUG io.lettuce.core.RedisChannelHandler - dispatching command AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]

01:25:44.826 [Thread-3] DEBUG io.lettuce.core.protocol.DefaultEndpoint - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, epid=0x1] write() writeAndFlush command AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]

01:25:44.827 [Thread-3] DEBUG io.lettuce.core.protocol.DefaultEndpoint - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, epid=0x1] write() done

01:25:44.827 [lettuce-nioEventLoop-4-1] DEBUG io.lettuce.core.protocol.CommandHandler - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, chid=0x1] write(ctx, AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command], promise)

01:25:44.829 [lettuce-nioEventLoop-4-1] DEBUG io.lettuce.core.protocol.CommandEncoder - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379] writing command AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]

01:25:44.830 [lettuce-nioEventLoop-4-1] DEBUG io.lettuce.core.protocol.CommandHandler - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, chid=0x1] Received: 4 bytes, 1 commands in the stack

01:25:44.831 [lettuce-nioEventLoop-4-1] DEBUG io.lettuce.core.protocol.CommandHandler - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, chid=0x1] Stack contains: 1 commands

01:25:44.831 [lettuce-nioEventLoop-4-1] DEBUG io.lettuce.core.protocol.RedisStateMachine - Decode AsyncCommand [type=PUBLISH, output=IntegerOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]

01:25:44.831 [lettuce-nioEventLoop-4-1] DEBUG io.lettuce.core.protocol.RedisStateMachine - Decoded AsyncCommand [type=PUBLISH, output=IntegerOutput [output=0, error='null'], commandType=io.lettuce.core.protocol.Command], empty stack: true

01:25:44.831 [Thread-3] DEBUG io.lettuce.core.protocol.DefaultEndpoint - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, epid=0x1] flushCommands()

01:25:44.831 [Thread-3] DEBUG io.lettuce.core.protocol.DefaultEndpoint - [channel=0xb75e3dc8, /10.1.1.202:59522 -> /10.1.1.44:6379, epid=0x1] flushCommands() Flushing 0 commands

共有1个答案

柯建业
2023-03-14

可能的解决方案:

async.multi();
async.publish(l_namespace, l_message);
async.set(l_key, l_message); // for late subscribers to catch up
async.exec();
 类似资料:
  • 我有一个带有一个主服务器和两个从服务器的Elasticache设置。我仍然不确定如何传递主从RedisURI列表以构建用于。我只看到对具有单个主机和端口的标准配置的支持。 我知道在为Redis主/从配置Spring Data Redis时会遇到类似的问题 但我认为它不适用于ElastiCache主/从设置,因为目前上述代码将尝试使用MasterSlaveTopologyProvider来发现从IP

  • 我使用springboot 2.3.9.RELEASE的莴苣客户端连接AWS redis elasticcache主/从。I'am able to write and read but a error is抛出每隔5000ms一次 这项服务对我的pourpose很好,但我想删除错误或知道如何修复它。 我已经读了很多关于它的书,用AWS配置spring数据redis的最好方法是使用RedisticM

  • 当我重新启动redis时,会导致java.util.concurrent。ExecutionException:io.莴苣.core。RedisCommandExecutionException:不需要身份验证。为什么使用这样的版本会出现问题

  • 我使用redis与阿卡,所以我不需要阻止调用。生菜内置了异步未来调用。但是Jedis是Redis推荐的客户。有人能告诉我我是否正确地使用了它们。如果是这样,哪一个更好。 绝地武士我正在使用一个静态绝地武士连接池来获取con,并使用Akka future回调来处理结果。我在这里关心的是,当我使用另一个线程(可调用)来获得结果时,该线程最终将阻止该结果。而莴苣可能有更有效的方法。 莴苣 如果莴苣是异步

  • 这类似于如何指定要运行哪个场景的问题 在问题中,他们给出了每个场景使用一个标记的示例。我想知道是否可以添加更多标签,比如在TestNG中,可以添加多个组。

  • 我们有一个Spring Boot应用程序,它被部署到AWS的EC2实例中包含的tomcat上。在本地我有redis设置。在我的申请中。yml我的redis配置如下: 我们用java对其进行了如下配置: 而我在QA中的集群负载平衡器url如下所示: aq***************亚马逊。com:6379实际上隐藏了所有redis集群。 我在本地测试了这个配置。。。。。。还有QA url。 但是不