2016年12月5日星期一

Fuse_022:Quickstarts camel-amq 例子演示

环境:JBoss Fuse 6.3

camel-amq 例子部署架构如下:

1. 安装 JBoss Fuse 6.3
(1)unzip jboss-fuse-karaf-6.3.0.redhat-187.zip
(2)vim jboss-fuse-6.3.0.redhat-187/etc/users.properties 去掉 admin 注释
(3)mv jboss-fuse-6.3.0.redhat-187 jboss-fuse-6.3.0-camel-amq
(4)cd jboss-fuse-6.3.0-camel-amq/bin
(5)./fuse

2. 编译与部署
(1)fabric:create --wait-for-provisioning
(2)cd quickstarts/camel-amq
(3)mvn clean install
    这一步会报如下错误:
    [ERROR] Failed to execute goal on project camel-amq: Could not resolve dependencies for project org.jboss.quickstarts.fuse:camel-amq:bundle:6.3.0.redhat-187: Could not find artifact rome:rome:jar:1.0.0.RC2-redhat-1 in redhat-ga-repository (https://maven.repository.redhat.com/ga) -> [Help 1]
    在 Nexus 中增加 JBoss Fuse Internal repository 后,编译通过。







    http://download-node-02.eng.bos.redhat.com/brewroot/repos/jb-fuse-6.2-build/latest/maven/

(4)mvn fabric8:deploy 账户/口令: admin/admin
    Maven settings file: /Users/maping/.m2/settings.xml


    There is no section in your ~/.m2/settings.xml file for the server id: fabric8.upload.repo

    You can enter the username/password now and have the settings.xml updated or you can do this by hand if you prefer.

    Would you like to update the settings.xml file now? (y/n): y
    Please let us know the login details for this server: fabric8.upload.repo

    Username: admin
    Password:
    Repeat Password:

    Copied original: /Users/maping/.m2/settings.xml to: /Users/maping/.m2/settings.xml.backup-1.xml
    Updated settings file: /Users/maping/.m2/settings.xml

3. 运行

3.1 使用命令行
(1)mq-create --kind StandAlone --group mygroup mybroker // 创建一个 A-MQ standalone broker,命名为 mybroker,并且属于 mygroup 组
    mq-create --kind MasterSlave --group mygroup mybroker
(2)container-create-child --profile mq-broker-mygroup.mybroker root mybroker // 创建一个子 container,并发布刚刚创建的 profile 到该 container
(3)fabric:container-create-child --profile quickstarts-camel.amq --profile mq-client-mygroup root mychild // 创建一个子 container 的同时,发布 quickstarts-camel.amq Profile 和 mq-client-mygroup Profile 到该 container。注意,第2个 Profile 使用了 mygroup,表明连接到 mygroup 组中的 broker。也就是说,你可以创建多个 A-MQ Broker,分别属于不同的组。
(4)fabric:container-list

3.2 使用 web console
(1)Fabric -> MQ,点击 +Broker,
    Kind 选择 StandAlone
    Group 输入 mygroup
    Broker name 输入 mybroker
    点击 √Create broker
(2)点击红色的叹号三角图标,创建 container,
    Container Name 输入 mybroker
    点击 √Create and start container
(3)Wiki,点击 quickstarts -> camel.amq,点击 New,
    Container Name 输入 mychild
    点击 √Create and start container
(4)Containers,点击 mychild,Associated Profiles 点击 +Add
    输入 my,选择 Mq/Client -> mygroup




4. 测试

4.1 使用命令行
(1)cp src/main/fabric8/data/*.xml /Users/maping/Redhat/fuse/demo/6.3/jboss-fuse-6.3.0-camel-amq/instances/mychild/work/jms/input/
(2)等一会,会发现
    * order1.xml 在 work/jms/output/others 目录中
    * order2.xml order4.xml 在 work/jms/output/uk 目录中
    * order3.xml order5.xml 在 work/jms/output/us 目录中
(3)log:display

4.2 使用 web console
(1)Containers,点击 mychild,点击 ->Open,在一个新的网页打开 mychild
(2)Camel,点击 Endpoints,展开,
    点击 file://work/jms/input,点击 Send->Choose
      勾选 data/order1.xml
      勾选 data/order2.xml
      勾选 data/order3.xml
      勾选 data/order4.xml
      勾选 data/order5.xml
    点击 Send 5 files // TODO 提示发不出去 ???
(3)Camel,点击 jms-cbr-route,展开,点击 Route Diagram,观察
(4)log:display




5 卸载

5.1 使用命令行
(1)fabric:container-stop mychild
(2)fabric:container-delete mychild
(3)fabric:container-stop mybroker
(4)fabric:container-delete mybroker

5.2 使用 web console
(1)Containers,选中 mybroker 和 mychild,点击 Stop,点击 Delete

参考文献:
1. https://github.com/jboss-fuse/quickstarts

没有评论: