【问题标题】:How do you retrieve an object from the ObjectStoreModule in Mule using Java?如何使用 Java 从 Mule 中的 ObjectStoreModule 中检索对象?
【发布时间】:2014-06-06 07:23:28
【问题描述】:

我有一个 ObjectStoreModule 配置为将一些 JSON 存储为字符串。根据规范 (http://mulesoft.github.io/mule-module-objectstore/java/org/mule/modules/ObjectStoreModule.html),我希望能够调用检索并获取我存储的对象的副本。但是,当我尝试这个时,我似乎只得到了返回的键而不是对象本身......

这是我的代码目前的样子。

ObjectStoreModule objectStore = (ObjectStoreModule) eventContext.getMuleContext().getRegistry().lookupObject("sourceConfigStore");

objectStore.store("KEY", jsonAsString, true);

System.out.println((String)objectStore.retrieve("sourceConfigStore", "KEY", null, null, eventContext.getMessage()))

目前,这只会打印出“KEY”,而不是名为 jsonAsString 的变量。我意识到检索方法还有其他输入参数将指定一个 mule 消息属性以将检索到的对象分配给,但我希望能够从 java 中与此存储进行交互,而无需将这些值分配给 mule 的额外步骤消息属性。

【问题讨论】:

    标签: mule


    【解决方案1】:

    我没有将正确的参数传递给 ObjectStoreModule 的 retrieve() 方法。第一个是“键”,第二个是在找不到键时返回的默认值。我将商店的名称和密钥作为默认值传递,这就是为什么返回的值是密钥,因为在商店本身中无法找到商店的名称作为密钥……哎呀。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-15
      • 1970-01-01
      • 2014-06-02
      相关资源
      最近更新 更多