`
happmaoo
  • 浏览: 4347905 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Mule+Spring+jbpm

阅读更多
<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog01.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>

法一:完全在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><br><bean id="restaurantWaiter" singleton="false" class="com.foo.RestaurantWaiter"><br><property name="kitchenService"><ref local="kitchenService"></ref></property><br></bean><br><bean id="kitchenService" class="com.foo.KitchenService"></bean><br></beans>

2 mule.xml
<mule-descriptor name="Restaurant Waiter"></mule-descriptor>inboundEndpoint="vm://order.queue"
implementation="restaurantWaiter">

为了让Mule能够识别restaurantWaiter,需要配置
<mule-configuration><br>....<br><container-context classname="org.mule.extras.spring.SpringContainerContext"><br><properties><br><property name="configFile" value="../conf/applicationContext.xml"></property><br></properties><br></container-context><br>....<br></mule-configuration>

Spring+jbpm+mule 三者是可以完美结合的

<!-- JBPM Datasource -->
<bean id="jbpmDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><br><spring-property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></spring-property><br><spring-property name="url"><value>jdbc:hsqldb:mem:.;sql.enforce_strict_size=true</value></spring-property><br><spring-property name="username"><value>sa</value></spring-property><br><spring-property name="password"><value></value></spring-property><br></bean>

<!-- JBPM Hibernate SessionFactory -->
<bean id="jbpmSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><br><spring-property name="dataSource"><br><ref local="jbpmDataSource"></ref><br></spring-property><br><spring-property name="mappingLocations"><br><value>classpath*:/org/jbpm/**/*.hbm.xml</value><br></spring-property><br><spring-property name="typeDefinitions"><br><ref local="jbpmTypes"></ref><br></spring-property><br><spring-property name="hibernateProperties"><br><props><br><prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop><br><prop key="hibernate.c3p0.min_size">1</prop><br><prop key="hibernate.c3p0.max_size">3</prop><br><prop key="hibernate.show_sql">false</prop><br><prop key="hibernate.query.substitutions">true 1, false 0</prop><br><prop key="hibernate.jdbc.batch_size">0</prop><br><!-- Create/update the database tables automatically when the JVM starts up --><br><prop key="hibernate.hbm2ddl.auto">update</prop><br></props><br></spring-property><br></bean>

<!-- JBPM data types -->
<bean id="jbpmTypes" class="org.springframework.orm.hibernate3.TypeDefinitionBean"><br><spring-property name="typeName"><value>string_max</value></spring-property><br><spring-property name="typeClass"><value>org.jbpm.db.hibernate.StringMax</value></spring-property><br></bean>

<!-- jBPM Configuration -->
<bean id="jbpmConfig" class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBeanWorkaround"><br><spring-property name="sessionFactory"><br><ref local="jbpmSessionFactory"></ref><br></spring-property><br><spring-property name="configuration"><br><value>jbpm.cfg.xml</value><br></spring-property><br><spring-property name="processDefinitions"><br><spring-list><br><bean id="loanBroker" class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean"><br><spring-property name="definitionLocation"><br><value>loan-broker-process.xml</value><br></spring-property><br></bean><br></spring-list><br></spring-property><br><spring-property name="createSchema"><value>false</value></spring-property><br></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中使用

<!-- ***************************************************<br /> BPMS Configuration<br /> *************************************************** -->
<!-- BPMS object for Mule's BPM Connector -->
<bean id="jbpm" class="org.jbpm.msg.mule.Jbpm" destroy-method="destroy"><br><spring-property name="jbpmConfiguration"><br><ref local="jbpmConfig"></ref><br></spring-property><br></bean>


mule.xml

<connector name="jBpmConnector" classname="org.mule.providers.bpm.ProcessConnector"><br><properties><br><!-- This field in LoanQuoteRequest holds the unique process ID. --><br><property name="processIdField" value="requestId"></property><br><!-- jBpm itself is configured by a series of Spring beans at the end of<br /> this file. --><br><spring-property name="bpms"><ref local="jbpm"></ref></spring-property><br></properties><br></connector>

mule in spring-context

muleContext.xml

<bean id="muleManager" class="org.mule.config.spring.config.UMOManagerFactoryBean"><br><property name="configuration"><ref local="muleConfiguration"></ref></property><br><property name="messageEndpoints"><ref local="messageEndpoints"></ref></property><br><property name="connectors"><ref local="connectorList"></ref></property><br><property name="transformers"><ref local="transformerList"></ref></property><br><property name="endpoints"><br><list><br><ref local="globalInboundJmsEndpoint"></ref><br><ref local="globalOutboundJmsEndpoint"></ref><br><ref local="globalHttpEndpoint"></ref><br></list><br></property><br><property name="interceptorStacks"><ref local="interceptorsMap"></ref></property><br><property name="model"><ref local="model"></ref></property><br></bean>

or 一种简单一些的配置

muleContext.xml

<bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean" destroy-method="dispose" singleton="true"></bean>
<!-- Used to set mule object names to their corresponding bean id -->
<bean id="muleNameProcessor" class="org.mule.extras.spring.config.MuleObjectNameProcessor"></bean>
<!-- 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"></bean>

web.xml

<context-param><br><param-name>contextConfigLocation</param-name><br><param-value>/WEB-INF/mule-spring-config.xml</param-value><br></context-param>

<listener><br><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class><br></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

br /> "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);



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1600021


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics