ServiceMix - starts with the simplest example

ServiceMix无痛起步

有兄弟评论说,“看了之后,感觉和技术没边,好像一个怨妇再发牢骚,我们程序员需要的是真实的解决方案,哪怕是个hello world的例子”,这就是本文的由来。而且除了SerivceMix主页,其他地方能找到的ServiceMix入门文章基本没有,希望这篇B文能带对ServiceMix感兴趣的兄弟们入个门。

本文是ServviceMix 3.3 的hello world,如果有后续文章,将会采用最新的ServiceMix 4。

准备工作很简单。去SerivceMix主页 下载ServiceMix就不提了,解压下载的zip文件到一个目录。先加一个环境变量SERVICEMIX_HOME,然后把ServiceMix的 bin和lib分别加入path和classpath,%SERVICEMIX_HOME%/bin 和 %SERVICEMIX_HOME%/lib/*.jar。这么做主要就是为了方便测试。下面的例子在%SERVICEMIX_HOME% /examples/loan-broker目录下,本例细节可以参考http://servicemix.apache.org/loan-broker.html

先是看看怎么运行,和运行效果。在load-broker目录下的build.xml有运行这个例子的各种ant任务。这里用两个就行了setup和 run,setup是编译并发布到ServiceMix,run是执行客户端测试。打开个console执行ant setup部署这个SA到ServiceMix,再打开个console执行servicemix servicemix.xml把ServiceMix启动,回到刚才那个console执行ant run进行测试。本例中比较奇怪,在SU下面的servicemix.xml里面配置了5个bank。其实在运行时,选中哪个是随机的。没明白这么配置要突出ServiceMix什么特点。

代码什么的就不说了,打开看看就明白,用了很多ServiceMix的API,可以参考api-doc。

接下来说明两个概念SA(Service Assembly)和SU(Service Unit),关于SA可以参考http://servicemix.apache.org/what-is-a-jbi-sa-and-how-do-i-create-one.html ,关于SU可以参考http://servicemix.apache.org/what-is-a-jbi-su-and-how-do-i-create-one.html 。简单的说SA是JBI规范定义的部署单元,用来包装若干个SU,以便部署到JBI容器当中,和EAR的概念有几分相似,不过SA是单纯的SU存档文件。SU是JBI规范定义的服务单元,从根上说SU就是打包了的JBI component配置和要部署这个SU所必须依赖的东东,可以用ServiceMix提供的Maven archetypes来创建SU。

再来看看SA和SU的结构,这些都是JBI规范要求的。SA打包之后在META-INF下面有一个jbi.xml,该文件说明了SA的结构,说白了就是SA套SU。SU下面的servicemix.xml说明了SU的结构。

下面两个是JBI的地址,对规范感兴趣的兄弟可以下来看看。
JBI1.0 http://jcp.org/aboutJava/communityprocess/final/jsr208/index.html
JBI2.0 http://jcp.org/en/jsr/detail?id=312

Comments

supra skylow

Do you like supra skylow shoes? If you are rich interested in buying shoes, I recommend you to click here supra skylow to visit our website to see all kinds of shoes you deeply love.Thank you for coming!

下次来点代码吧

RT

是喽,看不大懂...

是喽,看不大懂...来点代码就好了!

My site:湖师SVSE就业特色班

说得是啊

说得是啊,我说我的helloworld怎么就写不下去呢?
很可能就是没代码的问题。
以后多注意!

julian0zzx

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.