caching - Mule 4 - 使用 Redis 连接器作为自定义对象存储 "Connection is no longer valid"

标签 caching redis mule

我正在尝试使用 Redis 作为 Mule 4 项目的对象存储的后端。我已按照说明进行操作 here ,但是在项目启动时我不断收到错误消息:

Caused by: reactor.core.Exceptions$ReactiveException: org.mule.runtime.api.exception.DefaultMuleException: Obtained invalid connection from ObjectStore config 'ObjectStore_Config'. Error Type: UNKNOWN. Message: Connection is no longer valid

这是我的配置的截断 View :

<mule xmlns:redis="http://www.mulesoft.org/schema/mule/redis"
    xmlns:os="http://www.mulesoft.org/schema/mule/os"
    xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
    xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd 
http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd 
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd
http://www.mulesoft.org/schema/mule/redis http://www.mulesoft.org/schema/mule/redis/current/mule-redis.xsd">    

  ...

  <os:config name="ObjectStore_Config" doc:name="ObjectStore Config" doc:id="627a35b0-4b36-45e2-8ff6-fdd0eb9cb067">
    <redis:nonclustered-connection host="http://localhost:6379" />
  </os:config>

  <os:object-store name="Object_store" 
    config-ref="ObjectStore_Config"
    maxEntries="1"
    entryTtl="60"
    expirationInterval="10"
    expirationIntervalUnit="SECONDS"
    doc:name="Object store" 
    doc:id="bef9d4d3-0441-477c-a8b1-46626c95c9de" />  

  ...
</mule>

我在本地机器上从 docker 运行 Redis:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
126faa8c33a7        redis:3.2.12        "docker-entrypoint.s…"   5 days ago          Up 5 days           0.0.0.0:6379->6379/tcp   redis

我已经在一个单独的项目中验证了我可以使用 redis 连接器连接到这个实例并获取/设置数据。

为什么此连接不再适用于 ObjectStore 配置?

最佳答案

我将我的项目与 mule 支持提供的示例项目进行了比较 here并发现我需要添加 <redis:redis-config>元素,以及拆分我的 host redis:nonclustered-connection 上的属性嵌套在 os:config 内两者都是 hostport :

<os:config name="ObjectStore_Config">
  <redis:nonclustered-connection host="localhost" port="6379"/>
</os:config>

<redis:redis-config name="Redis_Redis" doc:name="Redis Redis" >
  <redis:nonclustered-connection />
</redis:redis-config>

关于caching - Mule 4 - 使用 Redis 连接器作为自定义对象存储 "Connection is no longer valid",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57576129/

相关文章:

redis - 在 getServerSideProps 中使用 redis 会导致错误 net.isIP is not a function

maven - tomcat上的mule maven应用程序

c# - 为什么ServiceStack中的Redis缓存客户端对于不存在的整数类型的key返回0而不是null?

redis - 如何在此 Redis Sentinel 配置中切换主节点?

caching - Eloquent 是否处理相关实体的缓存?

spring-boot - 如何反序列化 Redis 的 ResponseEntity?

java - 如何使用 Mule 读取邮件并插入数据库?

java - 从 Mule ESB 上的 java session 中读取变量

java - 尝试在 Spring-Hibernate 中启用二级 Hibernate 缓存时出错

django - gunicorn + redis : Does not work?