mule的jdbc,配置s
eda以及vm的初步认识
java类
package com.zxgllhh.jdbc;
import java.util.Map;
public class NumberServiceComponent {
public NumberServiceComponent(){
}
public Object process(Object vm) throws Exception{
Thread.
sleep(5000l);
System.out.print
ln();
Map map = (Map)vm;
System.out.println(\"NumberServiceComponent, jdbc message is \"+map.get(\"red_one\"));
System.out.println(\"NumberServiceComponent, this hashcode is \"+this.hashCode());
return \" ..... return NumberServiceComponent is : \"+vm +\" .....\";
}
}
配置文件
<?xml version=\"1.0\" e
ncoding=\"UTF-8\"?>
<mule xmlns=\"http://www.mulesource.org/schema/mule/core/2.2\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:spring=\"http://www.springframework.org/schema/beans\"
xmlns:soap=\"http://www.mulesource.org/schema/mule/soap/2.2\"
xmlns:cxf=\"http://www.mulesource.org/schema/mule/cxf/2.2\"
xmlns:stdio=\"http://www.mulesource.org/schema/mule/stdio/2.2\"
xmlns:vm=\"http://www.mulesource.org/schema/mule/vm/2.2\"
xmlns:cont
ext=\"http://www.springframework.org/schema/context\"
xmlns:jdbc=\"http://www.mulesource.org/schema/mule/jdbc/2.2\"
xsi:schemaLo
cation=\"
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/soap/2.2 http://www.mulesource.org/schema/mule/soap/2.2/mule-soap.xsd
http://www.mulesource.org/schema/mule/cxf/2.2 http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/jdbc/2.2 http://www.mulesource.org/schema/mule/jdbc/2.2/mule-jdbc.xsd\">
<description>
this is a description, to be expert or not to be is not a question.
To invoke the EchoUMO hit the following URL -
http://localhost:65082/services/EchoServiceUMO/echo/requestRe
sultByzxg/zxg
To view the WSDL for the EchoUMO service go to -
http://localhost:65082/services/EchoServiceUMO?wsdl
</description>
<spring:beans>
<spring:import resource=\"classpath:conf/applicationContext.xml\" />
</spring:beans>
<configuration>
<default-threading-pro
file maxThreadsActive=\"10\" maxBufferSize=\"10\" poolExhaustedAction=\"WAIT\"/>
<default-service-threading-profile maxThreadsActive=\"2\" maxBufferSize=\"2\" poolExhaustedAction=\"WAIT\"/>
</configuration>
<jdbc:connector name=\"jdbcConnectorActive\" pollingFrequency=\"10\" dataSource-ref=\"dataSource\">
<jdbc:query key=\"selectNumber\"
value=\"select t.red_one from win_number t where rownum between 0 and 10 \" />
</jdbc:connector>
<context:property-placeholder location=\"email.properties,system.properties\" />
<!-- CXF下的mule配置 -->
<vm:connector name=\"vmConnector\" queueEvents=\"
true\" />
<model name=\"echoSample\">
<service name=\"jdbcService\">
<inbound>
<jdbc:inbound-endpoint queryKey=\"selectNumber\" />
</inbound>
<!--
<component class=\"com.zxgllhh.jdbc.NumberServiceComponent\" />
-->
<!-- 使用对象池技术,在系统启动时就会先创建一批对象(本配置为10个)放在对象池里,等发起调用时,系统不会创建新的对象,because the component will reu
sed -->
<pooled-component class=\"com.zxgllhh.jdbc.NumberServiceComponent\">
<pooling-profile exhaustedAction=\"WHEN_EXHAUSTED_FAIL\" initialisationPolicy=\"INITIALISE_ALL\"
maxActive=\"5\" maxIdle=\"5\" maxWait=\"5\" />
</pooled-component>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system=\"OUT\"/>
</pass-through-router>
</outbound>
</service>
<service name=\"EchoService\">
<inbound>
<cxf:inbound-endpoint a
ddress=\"http://localhost:65082/services/EchoServiceUMO\"
serviceClass=\"com.zxgllhh.testMule.EchoService\"/>
</inbound>
<!-- 每次调用mule都会创建一个新的对象 -->
<component class=\"com.zxgllhh.testMule.impl.EchoComponent\" />
<!-- 配置一个vm Transport -->
<outbound>
<pass-through-router>
<vm:outbound-endpoint address=\"vm://orders\" />
</pass-through-router>
</outbound>
</service>
<!-- 接收vm传来的消息并做处理 -->
<service name=\"serviceName\">
<inbound>
<vm:inbound-endpoint address=\"vm://orders\" />
</inbound>
<!--
<component class=\"${vm-component}\" />
-->
<!-- 使用对象池技术,在系统启动时就会先创建一批对象(本配置为3个)放在对象池里,等发起调用时,系统不会创建新的对象,because the component will reused -->
<pooled-component class=\"${vm-component}\">
<pooling-profile exhaustedAction=\"WHEN_EXHAUSTED_FAIL\" initialisationPolicy=\"INITIALISE_ALL\"
maxActive=\"1\" maxIdle=\"2\" maxWait=\"3\" />
</pooled-component>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system=\"OUT\"/>
</pass-through-router>
</outbound>
</service>
</model>
<!--
<description>
this is a description, to be expert or not to be is not a question.
</description>
<model name=\"firstMuleModel\">
<service name=\"firstModelService\">
<inbound>
<stdio:inbound-endpoint system=\"IN\"/>
</inbound>
<component class=\"com.zxgllhh.testMule.impl.EchoComponent\"></component>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system=\"OUT\"/>
</pass-through-router>
</outbound>
</service>
</model>
-->
</mule>
spring配置文件
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or
morecontributor license agreements. See the NOTICE file distributed with
this work for additional info
rmation regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version
2.0 (the \"License\"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Un
less required by
applicable law or agreed to in writing, software distributed under the
License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either
express or implied. See the License for
the specific language governing permissions and limitations under the
License.
-->
<!-- START SNIPPET: beans -->
<beans xmlns=\"http://www.springframework.org/schema/beans\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:jaxws=\"http://cxf.apache.org/jaxws\"
xsi:schemaLocation=\"
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd\"
>
<!--
<import
resource=\"classpath:conf/framework/spring.framework.ibatis.xml\"></import>
<import
resource=\"classpath:conf/framework/__global/spring.framework.transaction.xml\"></import>
-->
<bean
id=\"dataSource\" class=\"com.
mchange.v2.c3p0.ComboPooledDataSource\" destroy-method=\"shutdown\">
<property name=\"driverClass\" value=\"oracle.jdbc.driver.OracleDriver\" />
<property name=\"jdbcUrl\" value=\"jdbc:oracle:thin:@127.0.0.1:1521:orcl\" />
<property name=\"acquireIncrement\" value=\"5\" />
<property name=\"initialPoolSize\" value=\"10\" />
<property name=\"maxPoolSize\" value=\"50\" />
<property name=\"minPoolSize\" value=\"10\" />
<property name=\"properties\">
<props>
<prop key=\"user\">ssq</prop>
<prop key=\"password\">ssq</prop>
</props>
</property>
</bean>
<!--
<bean id=\"transactionManager\"
class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\">
<property name=\"dataSource\">
<ref local=\"dataSource\" />
</property>
</bean>
<bean id=\"sqlMapClient\" class=\"org.springframework.orm.ibatis.SqlMapClientFactoryBean\">
<property name=\"configLocation\" value=\"classpath:conf/sqlmap.config.xml\" />
<property name=\"dataSource\" ref=\"dataSource\" />
</bean>
<bean id=\"sqlMapClientTemplate\" class=\"org.springframework.orm.ibatis.SqlMapClientTemplate\">
<property name=\"sqlMapClient\">
<ref bean=\"sqlMapClient\" />
</property>
</bean>
<bean id=\"SpringContextUti
ls\" class=\"com.tydic.framework.utils.spring.SpringContextUtils\" />
-->
</beans>
运行类
package com.zxgllhh.run;
import org.mule.api.MuleContext;
import org.mule.api.context.MuleContextFactory;
import org.mule.config.spring.SpringXmlConfigurationBuilder;
import org.mule.context.DefaultMuleContextFactory;
public class EagleMuleMain {
public
static void main(String[] args) throws Exception{
try {
String configFile = \"com/zxgllhh/run/mule-config.xml\";
String[] configFileArr = new String[] { configFile };
MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();