【问题标题】:In mule not able to retrieve value from Object Store in different application在 mule 中无法从不同应用程序中的对象存储中检索值
【发布时间】:2017-10-21 19:34:14
【问题描述】:

我无法从 App1 读取存储在对象存储中的键值。

我有 2 个应用程序 App1,它将变量的值(比如“名称”)存储到某个值(比如“abc”)。从 App2 中,我想检索键的值(在我们的例子中为“名称”),但它总是失败并出现 org.mule.api.store.ObjectDoesNotExistException。

如果两个流程都在同一个应用程序上,它可以工作,但这不是预期的行为。

两个应用程序都在同一个运行时运行,因此它应该能够检索该值。

下面是我的 App1 代码

<flow name="objectstore1Flow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/retrieve" allowedMethods="GET" doc:name="HTTP"/>
    <set-variable value="abc" variableName="name" doc:name="Variable" />
    <objectstore:store config-ref="ObjectStore__Connector" key="name" value-ref="#[flowVars.name]" doc:name="ObjectStore" />
</flow>

App2 的代码

<flow name="objectstore2Flow">
    <http:listener config-ref="gcc-httpDomainListenerConfig" path="/store2" allowedMethods="GET" doc:name="HTTP"/>
    <objectstore:retrieve config-ref="ObjectStore__Connector" key="name" doc:name="ObjectStore" targetScope="INVOCATION"/>
    <logger message="Value of name from cache is : #[payload]" level="INFO" doc:name="Logger"/>
</flow>

两个应用程序的对象存储配置是:

<objectstore:config name="ObjectStore__Connector" partition="name_value" doc:name="ObjectStore: Connector"/>

谁能指导我,我哪里出错了?

【问题讨论】:

    标签: mule mule-component mule-el mule-esb mule-cluster


    【解决方案1】:

    主要原因是两个应用程序相互独立,并使用自己的内存存储来保存数据。
    因此,当您的 app1 存储其数据时,它会存储在自己的内存中,而 app2 无法使用它,因为它是独立使用自己的内存中的。
    这两个应用程序都引用了它自己的对象存储配置。

    共享对象存储的解决方案将是一个域项目,您将在该域中定义一个单个对象存储,并将在其所有子应用程序之间共享,例如 app1强>、app2app3

    按照此处的步骤操作:- http://bushorn.com/dealing-with-store-the-object-store/

    对于 Persisting ObjectStore,使用 _defaultUserObjectStorePersistent 选项参考:https://docs.mulesoft.com/mule-user-guide/v/3.9/object-store-connector#persistingdata

    【讨论】:

    • 我确实尝试过 bushorn.com 中提到的方法,但没有奏效。在您发表评论后,我在重新启动 Studio 后尝试过,奇怪的是它现在可以正常工作了。我假设它不可能已经存在,否则我会得到 ObjectAlreadyExist 异常,这可能是我之前做错的事情。感谢您的建议,它现在可以工作了,现在将在集群的 Mule 盒子上检查这个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多