Skip to main content

JSOA-P 5 - 安裝與第一個Hello World for ESB

這裡講的是JBoss SOA 的企業版本. 裡面包含了企業需要使用的SOA 功能,像是 ESB, jBPM, Data Service 等等...

安裝JBoss SOA 跟其他JBoss 的家族是一樣的,unzip 之後就可以使用了!
在企業板有兩個選擇,一個是Standalone 的,比較適合一般開發者,另一個則是SOA-P , Production 環境用,最大的差別在於是否支援 Cluster.

點選download 之後就可以下載。我這次下載的版本為開發用的SOA.
我把Folder rename 成 soa-5 這是為了偷懶~(想用Tab鍵)

unzip 之後,到 $SOA_PATH/jboss-esb/server/default/conf/props 下,修改 , 加入自己的 id or password. (我使用的是預設值,所以直接砍掉最前面的#即可)

如果你有自己新增一個使用者,請不要忘記,把 裡面加上自己的 username,

完成之後就可以第一次開始啓動 SOA 了。
到$SOA_PATH/jboss-esb/bin 直接執行
啓動的時間大約 2 分鐘,啓動完畢看到 log 沒有 error ,使用瀏覽器到http://IP_ADDRESS:8080/ 看到以下畫面,表示安裝成功了!


設定JBoss Developer Studio

(在寫程式之前,請先安裝好 JBoss Developer Studio,這裡可以去註冊下載試用 當然,如果你想用Eclipse 也可以,但是所有的 plugin 請自己抓取,就不再贅述。 )

打開JBDS後,先選一個workspace, 然後進入

1. 設定SOA Runtime 環境。
先到Preference 下,

選擇左邊的 server 再選擇 Runtime Environments,右手邊,按下add

輸入這個runtime 的名字 : JBoss SOA Standalone
安裝的位置: $SOA_PATH/jboss-esb/
與 server 的 profile, 因為是standalone, 內建就是default.

按下Finish 完成。
接下來就是在這個workspace 連結到我們剛剛建立的server 上。
到Server 的 console, 按下滑鼠右鍵新增server

選擇 JBoss Enterprise Application Platform 5.x 然後輸入你要的server 名字。

按下Finish 即完成了server 的設定。

講一下JBoss SOA 的Service, 一個JBoss 的Service 必須先定義一個Listener,看是由哪裡進來的(FTP, Queue, Http... 等等),並且由很多的Action 組成,每個Action 負責許多的事情,例如,寫Log ,將資料轉型,甚至是轉到另外一個流程去,也可以去呼叫商業邏輯的物件。

Listener 接收器 又分成兩個,
Gateway Listeners:
ESB Aware Listeners:

Hello World
建立第一個 ESB的 Service.

由Client 發送一個訊息進入ESB 的其中一個點,Queue.
當資料透過Queue的這個連接點進入後,透過ESB 上設定專門聽這個queue 的Action 就會啓動,把訊息的資料列印出來。

1. 建立等一下要跑的queue 環境。新增一個 jbm-queue-service.xml
在Project 的路徑下,建立兩個Queue


2. 開始建立Provider, 設定告訴這個ESB 總共有多少的服務提供在上面。

A. XML 設定

B. Eclipse 設定
i. 打開 jboss-esb.xml (所有的ESB都是在上面設定的)
選擇左邊的Provider, 在右邊選擇Add, 然後按下 JMS Provider,

輸入 Provider 的名字。JBossMQ, 與選擇ConnectionFactory. 

輸入Channel ID: quickstartGwChannel

選擇左方新建的JBossMQ 下的Filter, 填入這個Provider 的對應位置,也就是剛剛建立的在JBoss 中 Queue 其中的一個。
另一個Provider 也請照剛剛的步驟建置 
Name: quickstartEsbChannel
ConnectionFactory: ConnectionFactory
Channel ID: quickstartEsbChannel
Destination Name:queue/quickstart_helloworld_Request_gw
Destination Type: QUEUE

3. 建立一個新的Service, 
A. XML 設定


B. Eclipse 設定
左邊選擇Service, 選擇Add 分別輸入以下三個值

4. 連結Provider 的在Service中建立Listener 
A. XML 設定


B. Eclipse 設定
按下左邊Listener, 選擇Add 輸入 Name 與選擇剛剛建立的Provider,

另一個Listener 也照剛剛的步驟建置 
Name: helloWorld
Channel ID Ref: quickstartEsbChannel

5. 建置與設定Action

選擇package 與 Action Name 


A. XML 設定Action 在Service中
B. Eclipse 在左邊選擇Actions, 點選Add, 設定Custom Action

設定名稱,選擇剛剛建立的Action Class

以上,第一個Service 就設定完畢了!很簡單吧!

package com.omni.test;

import java.util.Properties;
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class TestJMSMsg {
    QueueConnection conn;
    QueueSession session;
    Queue que;

    public void setupConnection() throws JMSException, NamingException{
        Properties properties1 = new Properties();
        properties1.put(Context.PROVIDER_URL, "jnp://");
        InitialContext iniCtx = new InitialContext(properties1);

        Object tmp = iniCtx.lookup("ConnectionFactory");
        QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
        conn = qcf.createQueueConnection();
        que = (Queue) iniCtx.lookup("queue/quickstart_helloworld_Request_gw");
        session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
        System.out.println("Connection Started");

    public void stop() throws JMSException{

    public void sendAMessage(String msg) throws JMSException {

        QueueSender send = session.createSender(que);        
        ObjectMessage tm = session.createObjectMessage(msg);
        System.out.println("MSG Sent:["+msg+"]");

    public static void main(String args[]) throws Exception{                    
     TestJMSMsg sm = new TestJMSMsg();


看到ESB 的Action 列印出訊息內容,表示完成拉!


Popular posts from this blog

Fuse Integration Service - Setup JBDS and create first quickstart application

Before we go and start creating our first application, I want to show you how to setup your JBoss Developer Studio, create a small application from the quickstart example and then running it on Fuse Integration Service.

I am using JBoss Developer Studio version 9, you can find it here.
After download the

double-click it, and start installing with default values.

After successful installation, we will need install the plugins for Fuse, on JBoss Central view, select software update, select enable early access.

And select JBoss Fuse Development for the plugin,

Click on install, and we are all set to go!

First thing first, we want to create a Fuse project to deploy on the base of Fuse Integration Service, which is OpenShift. If you have not installed it, please go back to my previous post for instructions. So on your JBDS, right click and start creating the project. Select new, maven project, if you have installed the plugin correctly, you should …

Red Hat JBoss Fuse/A-MQ - Fuse and A-MQ Version 6.3 GA is released!

Fuse and A-MQ 6.3 GA has just went out. Maybe, you would think this is just only a minor version release why should I care? Hold your thoughts on that! Because they have done a lot of improvements and also added many new features into this release.

Besides various bug fixes and making sure Fuse Fabric is much more stable. There are two major change in this version update:

New Tooling in JBoss Developer Studio (JBDS) 9.1 GA. Newer Apache Camel version – Camel v2.17. I was really impressed by the work put in to make developing Camel application much simpler. First is the installation of tooling itself. Now it has a all-in-one installer so you don't need to worry about which plugins you need to check. See the videos below to see the new "Getting Started" of Fuse 6.3.

And If you notice from the above video, the presentation of camel route in JBDS has also updated. It fixed some of the miss representation of logic and making it easier to read.

Old Camel Route
New Camel Route
On …

RHTE - Supercharge your integration services

Red Hat Tech Exchange has taken place in Vietnam, Ho Chi Minh city two weeks ago, it is a great event held by Red Hat in Asia Pacific Region. It is open to all Red Hat partners who are interested in learning what Red Hat is doing recently, see what the trend of the open source world, basically it is a great event to share your knowledge and experience, to meet other enthusiastic people.

I am very fortunate to talk in this great event, to talk about the things I have been working on and even discuss it with many. Also got lots of great ideas too. So here are the slide.

My first talk was with Thomas Qvarnström about how to handle large size data in JBoss Fuse and how JBoss Data Grid can help in the situation.

Here is the agenda of the talk, we will be talk about this in the up coming webinar on 24th Sept.

Integration often involves storing, retrieving, and transforming data. Using a traditional database in your integration is likely to becomes a bottleneck that is expensive and hard to …