---
title: "mule & seda 学习二 "
author: "hamlzf"
date: "2011-11-03T09:11:12Z"
tags: ["SOA", "mule"]
categories: ["企业架构"]
slug: "mule-seda"
draft: false
lastmod: "2011-11-02T17:22:38Z"
id: 1231399
url: "https://hamlzf.iteye.com/blog/1231399"
---

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 +" ....."; } } 配置文件 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 spring配置文件 ssq ssq 运行类 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(); } } } 一个名为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; } }