法一:完全在spring.xml里面配置mule的所有内容
该方法的缺点的是配置umo比mule语法更加繁琐
法二:两个配置分件都用,不过mule里面需要加入一些mule-spring的标记
其本质是将mule.xml转换成法一中的spring.xml
该方法比较适合在现有的spring应用中,加入mule
法三:在mule server的container内启动spring,各自用自己的配置文件格式,适用于以mule server为主,spring为辅的应用
假设有两个bean,restaurantWaiter和kitchenService,前者作为UMO来接收消息,然后调用service
1 spring-context.xml
<beans>
<bean id='restaurantWaiter' singleton='false' class='com.foo.RestaurantWaiter'>
<property name='kitchenService'><ref local='kitchenService'/></property>
</bean>
<bean id='kitchenService' class='com.foo.KitchenService'/>
</beans>
2 mule.xml
<mule-descriptor name="Restaurant Waiter"
inboundEndpoint="vm://order.queue"
implementation="restaurantWaiter">
</mule-descriptor>
为了让Mule能够识别restaurantWaiter,需要配置
<mule-configuration>
....
<container-context className='org.mule.extras.spring.SpringContainerContext'>
<properties>
<property name='configFile' value='../conf/applicationContext.xml'/>
</properties>
</container-context>
....
</mule-configuration>
Spring+jbpm+mule 三者是可以完美结合的
<!-- JBPM Datasource -->
<bean id="jbpmDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<spring-property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></spring-property>
<spring-property name="url"><value>jdbc:hsqldb:mem:.;sql.enforce_strict_size=true</value></spring-property>
<spring-property name="username"><value>sa</value></spring-property>
<spring-property name="password"><value></value></spring-property>
</bean>
<!-- JBPM Hibernate SessionFactory -->
<bean id="jbpmSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<spring-property name="dataSource">
<ref local="jbpmDataSource" />
</spring-property>
<spring-property name="mappingLocations">
<value>classpath*:/org/jbpm/**/*.hbm.xml</value>
</spring-property>
<spring-property name="typeDefinitions">
<ref local="jbpmTypes" />
</spring-property>
<spring-property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.c3p0.min_size">1</prop>
<prop key="hibernate.c3p0.max_size">3</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.query.substitutions">true 1, false 0</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<!-- Create/update the database tables automatically when the JVM starts up -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</spring-property>
</bean>
<!-- JBPM data types -->
<bean id="jbpmTypes" class="org.springframework.orm.hibernate3.TypeDefinitionBean">
<spring-property name="typeName"><value>string_max</value></spring-property>
<spring-property name="typeClass"><value>org.jbpm.db.hibernate.StringMax</value></spring-property>
</bean>
<!-- jBPM Configuration -->
<bean id="jbpmConfig" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBeanWorkaround">
<spring-property name="sessionFactory">
<ref local="jbpmSessionFactory"/>
</spring-property>
<spring-property name="configuration">
<value>jbpm.cfg.xml</value>
</spring-property>
<spring-property name="processDefinitions">
<spring-list>
<bean id="loanBroker" class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
<spring-property name="definitionLocation">
<value>loan-broker-process.xml</value>
</spring-property>
</bean>
</spring-list>
</spring-property>
<spring-property name="createSchema"><value>false</value></spring-property>
</bean>
上面的部分已经足够将spring和jbpm结合起来了,appfuse中的集合也就做到上面的步骤
该集成使用了spring-modules-jbpm31.jar
具体使用的演示
JbpmConfiguration config = (JbpmConfiguration) applicationContext.getBean("jbpmConfig");
JbpmContext context = config.createJbpmContext();
ProcessDefinition definition = context.getGraphSession().findLatestProcessDefinition("testProcess");
//下面是mule中使用jbpm的配置,使用org.jbpm.msg.mule.Jbpm对其进行了封装,以便在jBpmConnector中使用
<!-- ***************************************************
BPMS Configuration
*************************************************** -->
<!-- BPMS object for Mule's BPM Connector -->
<bean id="jbpm" class="org.jbpm.msg.mule.Jbpm" destroy-method="destroy">
<spring-property name="jbpmConfiguration">
<ref local="jbpmConfig" />
</spring-property>
</bean>
mule.xml
<connector name="jBpmConnector" className="org.mule.providers.bpm.ProcessConnector">
<properties>
<!-- This field in LoanQuoteRequest holds the unique process ID. -->
<property name="processIdField" value="requestId" />
<!-- jBpm itself is configured by a series of Spring beans at the end of
this file. -->
<spring-property name="bpms"><ref local="jbpm" /></spring-property>
</properties>
</connector>
mule in spring-context
muleContext.xml
<bean id="muleManager" class="org.mule.config.spring.config.UMOManagerFactoryBean">
<property name="configuration"><ref local="muleConfiguration"/></property>
<property name="messageEndpoints"><ref local="messageEndpoints"/></property>
<property name="connectors"><ref local="connectorList"/></property>
<property name="transformers"><ref local="transformerList"/></property>
<property name="endpoints">
<list>
<ref local="globalInboundJmsEndpoint"/>
<ref local="globalOutboundJmsEndpoint"/>
<ref local="globalHttpEndpoint"/>
</list>
</property>
<property name="interceptorStacks"><ref local="interceptorsMap"/></property>
<property name="model"><ref local="model"/></property>
</bean>
or 一种简单一些的配置
muleContext.xml
<bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean" destroy-method="dispose" singleton="true"/>
<!-- Used to set mule object names to their corresponding bean id -->
<bean id="muleNameProcessor" class="org.mule.extras.spring.config.MuleObjectNameProcessor"/>
<!-- The mule client we will use to send events to the mule server -->
<bean id="muleClient" class="org.mule.extras.client.MuleClient" depends-on="muleManager"/>
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/mule-spring-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
这样spring启动的时候,mule server也就启动了
========
使用spring和mule混合标签的config.xml
SpringConfigurationBuilder builder = new SpringConfigurationBuilder();
UMOManager manager = builder.configure("mule-spring-config.xml,mule-spring-components.xml");
接下来不需要做任何处理,因为之后都会通过
MuleManager.getInstance() 来获得该manager
<!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN"
"http://www.symphonysoft.com/dtds/mule/mule-spring-configuration.dtd">
//create a client
MuleClient client = new MuleClient();
//send a jms message asynchronously
client.dispatch("jms://my.queue", "some data", null);
//or to receive a pop3 message via a configured mailbox
UMOMessage message = client.receive("pop3://myInboxProvider", 3000);
//or synchonous send a inter-vm message
UMOMessage message2 = client.send("vm://my.object", "Some more data", null);
分享到:
相关推荐
NULL 博文链接:https://exjava2.iteye.com/blog/1451974
使用mule-spring-boot-starter,您可以运行Spring Boot应用程序中嵌入的Mule CE。 这使Mule开发人员无需下载Mule运行时,创建Maven工件并将工件推送到Mule运行时即可快速原型化和/或部署Mule应用程序。 该项目将...
mule in action 和doc文档详细介绍 Mule的核心组件是UMO(Universal Message Objects,从Mule2.0开始UMO这一概念已经被组件Componse所代替),UMO实现整合逻辑。UMO可以是POJO,JavaBean等等。它支持30多种传输协议...
MuleESB集成webservice+restful(sprintboot+mybatis+mysql)+activeMQ+javamail,五天的研究成果,集成了我所关注的点,希望有更多的朋友一起学习进步。
Spring Boot模块扩展添加描述... ... ... 将此依赖项添加到您的应用程序pom.xml <groupId>...
liferay 5.2.3 可實際用於建構 jbpm workflow portlet的 jbpm檔。 用這個檔案加上mule再參考網路上的設定文件,即可輕易的在5.2.3上完成workflow portlet的建置... mule檔太大,請在liferay網路上下載即可
Mule+Training+--+Ricston.pdf
mule_spring_hibernate_demo Spring和Hibernate的Mule持久性示例
mule-starter-app-入门级Spring Boot Mule嵌入式应用程序内容博客请查看。用法通过Gradle git clone https://github.com/glawson6/mule-starter-app.gitcd mule-starter-app ...使用./gradlew进行./gradlew ... ./...
Mule ESB 是一个轻量级的基于java的企业服务总线和集成平台, 使得开发人员可以快速,简单的连接多个应用, 使得它们可以交换数据。 Mule ESB 容易集成现有异构系统,包括:JMS, Web Services, JDBC, HTTP, 等. ESB...
It borrows from the Hohpe/Woolf patterns, is lightweight, can publish REST and SOAP services, integrates well with Spring, is customizable, scales well, and is cloud-ready. About the Book Mule in ...
Mule是一个以Java为核心的轻量级的消息框架和整合平台,基于EIP(Enterprise Integeration Patterns,由Hohpe和Woolf编写的一本书)而实现的。Mule的核心组件是UMO(Universal Message Objects,从Mule2.0开始UMO这一...
Mule是一个企业服务总线(ESB)消息框架,而且Mule是一个轻量级且高度可扩展的ESB。
关于在tomcat上进行mule多线程数量参数配置
mule -esb 源码
Mule is the most widely used open source ESB-with millions of downloads-providing an alternative to expensive commercial options. Mule in Action is acomprehensive tutorial designed for working Java ...