天天看点

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

1.概述

在实际业务环境中,某一个业务模块往往需要重复执行,这就需要使用循环来完成。AEAI ESB在流程化的设计模式中也支持循环的使用,本文档为读者介绍如何使用分支、合并路由设计循环流程。

2.样例

2.1.创建Http流程

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.2.整体流程图

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.3.参数说明

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.4.组件说明

2.4.1.httpRequest

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

   2.4.2.初始化内容

package com.aeai.demo.messageflows.simpleloop;

importcom.agileai.esb.core.AdapteException;

importcom.agileai.esb.component.flow.http.HttpRequest;

importcom.agileai.esb.component.transformer.JavaTransformer;

public classJavaConverter1 extends JavaTransformer{

        public void handleRequest() throwsAdapteException{

                 try {

                           HttpRequest req =(HttpRequest) getMessageFlow().getRequest();

                           String _counter =req.getParam("counter");

                           int counter =Integer.parseInt(_counter);

                           getVariable("index").setValue(0);                      //初始值

                           getVariable("counter").setValue(counter); //循环数

                 } catch (Exception e) {

                           logger.error(e.getLocalizedMessage(),e);

                           throw newAdapteException(e.getLocalizedMessage(),e);

                 }                                  

        }

}

2.4.3.循环合并

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.4.4.循环内容

package com.aeai.demo.messageflows.simpleloop;

importcom.agileai.esb.core.AdapteException;

importcom.agileai.esb.component.transformer.JavaTransformer;

public classJavaConverter2 extends JavaTransformer{

        public void handleRequest() throwsAdapteException{

                 try {

                           int index = (Integer)getVariable("index").getValue();

                           logger.info("循环第 " + (index + 1) + "次");

                           //循环++

                           getVariable("index").setValue(index+ 1);

                 } catch (Exception e) {

                           logger.error(e.getLocalizedMessage(),e);

                           throw new AdapteException(e.getLocalizedMessage(),e);

                 }                                  

        }

}

2.4.5.循环分支

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.4.6.HttpResponse

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.4.7.循环分支到循环合并连线 

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.4.8.循环分支待HttpResponse连线

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

2.5.测试

AEAI ESB-基于ESB的循环及判断处理控制 1.概述 2.样例

AEAI ESB-基于ESB的循环及判断处理控制文档   下载