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. 计算机二级题31套资料,计算机等级考试:二级VFP机试第31套
  2. java用流体加减乘除_任意输入两个数,完成加法、减法、乘法、除法运算!(加减乘除运算分别定义四个方法)_学小易找答案...
  3. stm32控制舵机任意角度_如何对舵机建模仿真?
  4. C语言——二分法查找一个数_数组
  5. 好的文案,极大的降低沟通成本
  6. 建议简书评论区升级筛选/排序功能
  7. python编程入门书籍-python入门书籍推荐
  8. excel 科学计数法转换成文本完整显示_Excel中的数字格式和文本格式转换
  9. android环境混合app开发,cordova混合App开发:Cordova+Vue实现Android (环境搭建)
  10. 黑马程序员vue前端基础教程-4个小时带你快速入门vue
  11. 2513: 小勇学分数(公约数问题)
  12. Excel学习日记:L18-CountifsSumifs函数
  13. os系统服务器防火墙怎么关闭,mac防火墙如何关闭
  14. Android存储子系统流程--vold
  15. 带你认识不一样的常春藤之一的普林斯顿大学
  16. iOS 获取当前时间之后N天的日期
  17. UINCODE字符串和安全字符串函数(好)
  18. 基础论文 (一) ADDA
  19. 郝健: github多人协作项目开发实操笔记
  20. 用PHP建设网站的优缺点

热门文章

  1. Linux 字体微调 - windows 效果版
  2. uva 12325(宝箱, 枚举问题);
  3. 刘翔因伤退出比赛,暴露了不少国人的本性
  4. Python赋值语句的多种形式
  5. word文档的只有横线的表格怎样做
  6. 灰色预测的MATLAB程序
  7. android如何拨打电话
  8. 牛逼了,用Python破解wifi密码
  9. Matlab(三)——图像处理实例:去除背景,提取指纹
  10. SSAO By Computer Shader(三)