mule的jdbc,配置seda以及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.println();
        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" encoding="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:context="http://www.springframework.org/schema/context"
       xmlns:jdbc="http://www.mulesource.org/schema/mule/jdbc/2.2"
    xsi:schemaLocation="
       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/requestResultByzxg/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-profile 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 reused -->
            <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 address="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 more
        contributor license agreements. See the NOTICE file distributed with
        this work for additional information 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 Unless 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="SpringContextUtils" 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();
            MuleContext context = muleContextFactory
                    .createMuleContext(new SpringXmlConfigurationBuilder(
                            configFileArr));
            context.start();
        } catch (Exception t) {
            t.printStackTrace();
        }
    }
}

<service name="jdbcService">
            <inbound>
                <jdbc:inbound-endpoint queryKey="selectNumber" />
            </inbound>
            <!--
            <component class="com.zxgllhh.jdbc.NumberServiceComponent" />
             -->
            <!-- 使用对象池技术,在系统启动时就会先创建一批对象(本配置为10个)放在对象池里,等发起调用时,系统不会创建新的对象,because the component will reused -->
            <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>
                    <vm:outbound-endpoint address="vm://orders" />
                </pass-through-router>
            </outbound>
        </service>

一个名为jdbcService的service组件从selectNumber得到数据(这个数据为map格式的colum/value)处理过后,还可以把消息发送到

vm://orders上等待下一步的执行。这就是分段式事件驱动架构。

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.println();
        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 map;
    }
}

package com.zxgllhh.vm;

public class VMComponent {
   
    public VMComponent(){
        System.out.println("init VMComponent...");
    }
   
    public Object process(Object vm){
        System.out.println("VMComponent, vm message is "+vm);
        System.out.println("VMComponent, this hashcode is "+this.hashCode());
        return "vm : "+vm;
    }
}

mule seda 学习二相关推荐

  1. C#多线程学习(二) 如何操纵一个线程

    C#多线程学习(二) 如何操纵一个线程 原文链接:http://kb.cnblogs.com/page/42529/ [1] C#多线程学习(二) 如何操纵一个线程 [2] C#多线程学习(二) 如何 ...

  2. spring security 学习二

    spring security 学习二 doc:https://docs.spring.io/spring-security/site/docs/ 基于表单的认证(个性化认证流程): 一.自定义登录页 ...

  3. STL源码剖析学习二:空间配置器(allocator)

    STL源码剖析学习二:空间配置器(allocator) 标准接口: vlaue_type pointer const_pointer reference const_reference size_ty ...

  4. mysql用创建的用户登陆并修改表格_MySQL 基础学习二:创建一个用户表,并增删改查...

    MySQL 基础学习二:创建一个用户表,并 增删改查 提示:MySQL 命令建议都用大写,因为小写运行时,还是翻译成大写的. 第一步,创建一个用户表 1,打开控制台,进入数据库 C:\Users\Ad ...

  5. OpenCV学习(二十四 ):角点检测(Corner Detection):cornerHarris(),goodFeatureToTrack()

    OpenCV学习(二十四 ):角点检测(Corner Detection):cornerHarris(),goodFeatureToTrack() 参考博客: Harris角点检测原理详解 Harri ...

  6. OpenCV学习(二十二) :反向投影:calcBackProject(),mixChannels()

    OpenCV学习(二十二) :反向投影:calcHist(),minMaxLoc(),compareHist() 参考博客: 反向投影backproject的直观理解 opencv 反向投影 颜色直方 ...

  7. OpenCV学习(二十一) :计算图像连通分量:connectedComponents(),connectedComponentsWithStats()

    OpenCV学习(二十一) :计算图像连通分量:connectedComponents(),connectedComponentsWithStats() 1.connectedComponents() ...

  8. OpenCV学习(二十) :分水岭算法:watershed()

    OpenCV学习(二十) :分水岭算法:watershed() 参考博客: OpenCV-分水岭算法 图像处理--分水岭算法 OpenCV学习(7) 分水岭算法(1) Opencv分水岭算法--wat ...

  9. OpenCV与图像处理学习二——图像直方图与色彩空间

    OpenCV与图像处理学习二--图像直方图与色彩空间 2.4 图像直方图(Image Histogram) 2.4.1 直方图的绘制 2.4.2 三通道直方图绘制 2.5 颜色空间 2.5.1 RGB ...

最新文章

  1. Python外卷(8)--pdist, squareform
  2. 前端开发 填充padding 0229
  3. 清北学堂dp图论营游记day4
  4. 贵州:2018经济增速继续领先 2019“九字真言”主攻高质量
  5. 家庭网络,怎么给每个房间装一个无线路由器?
  6. vue ui创建项目时ERROR Failed to get response from Error: JAVA_HOME is not set./vue-cli-version-marker
  7. 利用Adams对单摆进行建模、仿真的动力学分析
  8. matlab在傅里叶里的应用,MATLAB在傅里叶变换中的应用
  9. nginx错误代码说明,出现原因及解决方法
  10. 【信奥赛一本通】 1413:确定进制(详细代码)
  11. 大数据、人工智能、VR、Docker、前端,双11技术视频、讲义、文章一键get
  12. IDEA 一直卡在Buil(编译 write classes)报错资源不足
  13. android白屏优化方案,优化Android App启动白屏
  14. 洛谷P3374 【模板】树状数组 1
  15. 给通达信独立下单软件(tc.exe)加上快捷键 TCOEM.XML
  16. 一维数组cvs文件,求数据平均值
  17. 【最新重磅整理】82篇AAAI2021强化学习领域论文接收列表
  18. vscode中安装开发html5中需要的插件
  19. 采用软件定义数据中心 (SDDC) 和超融合基础架构 (HCI) 解决方案的 InterSystems 客户需要重点关注的事项...
  20. HTTP响应码大全详解

热门文章

  1. 微信公众账号的订阅号与服务号有什么区别?
  2. python二级证书考试难度_全国计算机等级考试 python二级考试体验及小技巧总结...
  3. 运筹说 第57期 | 整数规划的分支定界法
  4. JavaScript摘录(二)
  5. 按键判断之GetKeyState 和 GetAsyncKeyState 区别
  6. Android应用面试题及答案汇总
  7. Python变量赋值出现SyntaxError: invalid syntax
  8. 揭阳计算机短期培训机构,揭阳市PLC自动化速成班
  9. java全国二级考点,java计算机全国二级考试时间
  10. java基础_题库详解