如何在Mule应用之间共享数据不使用数据库(使用对象存储) [英] How to share data between mule apps don't use database(using object store)

查看:97
本文介绍了如何在Mule应用之间共享数据不使用数据库(使用对象存储)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在m子中使用对象存储时遇到问题.它不能与同一m子服务器上的其他应用程序共享数据.我已经设置了以下内容,但无法在其他应用程序(同一服务器)中使用.

I have a problem when using Object store in mule. It cannot share datas with another apps on the same mule server. I have set same as below but cannot using in another app(same server).

<spring:beans>
    <spring:bean id="myListableObjectStore"
        class="org.mule.util.store.SimpleMemoryObjectStore" />
</spring:beans>
<objectstore:config name="ObjectStore"
    objectStore-ref="myListableObjectStore" doc:name="ObjectStore" />

谁对此有任何解决方案,请帮助我.

Who have any solution about this, please help me.

非常感谢您!

推荐答案

随着Mule 3.5的引入,域的概念可用于在应用程序之间共享资源(尽管存在一些限制,如mule文档中所述) ).在这种情况下,您要共享对象存储spring bean.

With the introduction of Mule 3.5 there is the concept of domains which can be used to share resources between applications (although there are some limitations as described in the mule documentation). In this case you want to share the object store spring bean.

为了在Mule 3.5中做到这一点,您应该创建一个域来做到这一点:

In order to do this in Mule 3.5 you should create a domain to do so:

  1. 在$ MULE_HOME/domains(例如$ MULE/domains/mydomain)下创建一个文件夹
  2. 创建一个名为mule-domain-config.xml的文件,该文件应包含您所处域的配置,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<mule-domain xmlns="http://www.mulesoft.org/schema/mule/domain" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/domain http://www.mulesoft.org/schema/mule/domain/current/mule-domain.xsd  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd">
    <spring:beans>
        <spring:bean id="myListableObjectStore" class="org.mule.util.store.SimpleMemoryObjectStore" />
    </spring:beans>
</mule-domain>

然后,您需要创建一个使用域的应用程序.为此:

Then you need to create an application which uses the domain. To do so:

  1. 在Studio中创建一个新项目
  2. 在mule-deploy.properties中编辑域属性,该属性应为 设置为域名(例如mydomain)
  3. 还要确保在对象存储配置中引用了正确的对象存储Bean(在本例中为myListableObjectStore)
  1. In studio create a new project
  2. Edit the domain property in mule-deploy.properties this should be set to the domain name (e.g. mydomain)
  3. Also make sure that in the object store config is referring to the correct object store bean (in this case myListableObjectStore)

该应用程序的代码应类似于:

The code for the application should look something like:

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/current/mule-objectstore.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">



    <objectstore:config name="ObjectStore"
        objectStore-ref="myListableObjectStore" 
         />



<flow name="store" doc:name="store">
<http:inbound-endpoint address="http://localhost:8085" doc:name="HTTP"/>
<objectstore:store config-ref="ObjectStore" key="abc" value-ref="#[payload]" doc:name="ObjectStore"/>
</flow>


<flow name="retrieve" doc:name="retrieve">
<http:inbound-endpoint address="http://localhost:8084" doc:name="HTTP"/>
<objectstore:retrieve key="abc" config-ref="ObjectStore" doc:name="ObjectStore"/>
</flow>

此应用程序可以部署到通常的$ MULE_HOME/apps目录中,也可以将其部署到域文件夹下.

This app can be deployed both to the usual $MULE_HOME/apps directory or else you can deploy it under the domain folder.

要对此进行测试,请部署另一个应用程序,该应用程序将从对象存储中读取检索结果,例如:

To test this deploy another app that reads the retrieves from the object store such as :

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/current/mule-objectstore.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">



    <objectstore:config name="ObjectStore"
        objectStore-ref="myListableObjectStore" 
         />


<flow name="retrieve" doc:name="retrieve">
<http:inbound-endpoint address="http://localhost:8081" doc:name="HTTP"/>
<objectstore:retrieve key="abc" config-ref="ObjectStore" doc:name="ObjectStore"/>
</flow>

然后单击http://localhost:8085/mypayload,当您单击http://localhost:8081时,您应该在浏览器中看到/mypayload.

Then hit http://localhost:8085/mypayload and when you hit http://localhost:8081 you should see /mypayload in your browser.

这篇关于如何在Mule应用之间共享数据不使用数据库(使用对象存储)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆