您的当前位置:首页正文

整个流程拉通方案

2020-06-07 来源:小奈知识网


流程拉通方案

文档变更记录

序号 1 2

变更(+/-)说明 流程拉通方案 作者 方浩 版本号 1.0 日期 2016.8.23 批准

1. 引言

1.1 编写目的和范围

宇信emp集成dubbo,把各个业务做成接口通过dubbo对外提供服务。对于开发人员此文档作为开发规范,在了解整个流程的情况下,在指定的路径包下进行编码开发。对于业务人员帮助熟悉理解整个流程,更好的完成业务接口对接。

2. 整体设计

2.1 Web容器加载dubbo启动类

Tomcat

启动时读取配置文件

web.xml,web.xml

所在目录:

/cmismd/WebContent/WEB-INF/web.xml;

在web里增加servlet

ProviderInit

com.yucheng.cmis.dubbo.start.Provider 6

类Provider init()方类启动dubbo

2.2 Dubbo生产接口

生产接口流程图:

Dubbo启动时加载参数配制:applicationContextService.xml所在目录:

/cmismd/src/main/config/applicationContextService.xml

参数解析:

dubbo:application:提供方应用信息,用于计算依赖关系 dubbo:registry:使用注册中心暴露服务地址 dubbo:protocol:用dubbo协议在端口暴露服务 dubbo:service:声明需要暴露的服务接口 bean:接口实现类

每开发一个接口需要在配制文件applicationContextService.xml把接口注册到zookeeper示例如下:

Demo:

生产接口开发目录结构:

Demo:

服务接口类:目录:/cmismd/src/main/java/com/yucheng/cmis/dubbo/service 定义接口示例:ApplyNextTimeDubboService

package com.yucheng.cmis.dubbo.service;

import com.yucheng.cmis.dubbo.ob.ApplyNextTimeReqMsgBO; import com.yucheng.cmis.dubbo.ob.ApplyNextTimeRespMsgBO; /**

*

申请授信时间接口:

* @author yusys

* @moduleId com.yucheng.cmis.dubbo.service * @createDate 2016-8-23 10:09:59 */

public interface ApplyNextTimeDubboService {

/**

* 再次申请授信时间 */

public ApplyNextTimeRespMsgBO

queryApplyNextTime(ApplyNextTimeReqMsgBO applyNextTimeReqMsgBO) throws Exception;

}

服务接口实现类:目录:/cmismd/src/main/java/com/yucheng/cmis/dubbo/service/impl 接口实现类示例:ApplyNextTimeDubboServiceImpl

package com.yucheng.cmis.dubbo.service.impl; import java.sql.Connection; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map;

import javax.sql.DataSource;

import org.apache.commons.lang.time.DateUtils; import com.alibaba.dubbo.common.utils.StringUtils; import com.ecc.emp.component.factory.ComponentFactory;

import com.ecc.emp.component.factory.EMPFlowComponentFactory; import com.ecc.emp.core.Context;

import com.ecc.emp.jdbc.ConnectionManager; import com.yucheng.cmis.dao.SqlClient;

import com.yucheng.cmis.dubbo.ob.ApplyNextTimeReqMsgBO; import com.yucheng.cmis.dubbo.ob.ApplyNextTimeRespMsgBO;

import com.yucheng.cmis.dubbo.service.ApplyNextTimeDubboService; import

com.yucheng.cmis.retailloan.businessflow.lcapplLimit.domain.LcApplLimit; /**

*

申请授信时间接口实现:

* @author yusys

* @moduleId com.yucheng.cmis.dubbo.service * @createDate 2016-8-23 10:09:59 */

public class ApplyNextTimeDubboServiceImpl implements ApplyNextTimeDubboService{

private Connection conn; private DataSource dataSource; /**

* 再次申请授信时间实现方法 */

@SuppressWarnings({ \"unchecked\", \"rawtypes\" }) public ApplyNextTimeRespMsgBO

ApplyNextTimeRespMsgBO response= new ApplyNextTimeRespMsgBO(); if(applyNextTimeReqMsgBO !=null){

String idNo = applyNextTimeReqMsgBO.getIdNo();//证件号码 String idType = applyNextTimeReqMsgBO.getIdType();//证件类型 throws Exception {

queryApplyNextTime(ApplyNextTimeReqMsgBO applyNextTimeReqMsgBO)

String loanType = applyNextTimeReqMsgBO.getLoanType();//额度

//判断参数是否为空(默认为空)

if(StringUtils.isBlank(idNo) || StringUtils.isBlank(idType)

//查询条件其中为空的情况

response.setNextTime(0L);

throw new Exception(\"参数不为空\");

品种

|| StringUtils.isBlank(loanType)){

}else{

Context context = null; try {

context = ((EMPFlowComponentFactory)

ComponentFactory.getComponentFactory(\"CMISBiz\")).getContext(null,\"rootCtx\");

// 初始化数据库连接

dataSource = (DataSource) this.conn =

Map map =new HashMap(); map.put(\"idNo\", idNo); map.put(\"idType\", idType); map.put(\"loanType\", loanType); //查询数据库 LcApplLimit

context.getService(\"dataSource\");

ConnectionManager.getConnection(dataSource);

limit=(LcApplLimit)SqlClient.queryFirst(\"queryLcApplLimitForSeq\", map, conn);

SimpleDateFormat format = new //判断是否存在该数据 if(limit !=null){

String lastTime = limit.getLastChgDt();//获取

Date date =

response.setNextTime(date.getTime());

SimpleDateFormat( \"yyyy-MM-dd HH:mm:ss\");

最后修改时间

DateUtils.addDays(format.parse(lastTime), 100);

String d = format.format(date.getTime());

}

System.out.println(\"Format To

//返回的是最后修改的时间+阀值(p_limit_typ 这表中的 }else{

//不存在改数据时,返回当前时间 Date date = new Date();

String(Date):\"+d);

某个字段) }

}

}

}

response.setNextTime(date.getTime()); String d = format.format(date.getTime()); System.out.println(\"Format To

String(Date):\"+d);

}

} catch (Exception e) {

e.printStackTrace(); if(this.conn== null ){

this.conn.close(); //关闭连接 } }finally{

return response;

服务接口javabeen:目录:/cmismd/src/main/java/com/yucheng/cmis/dubbo/ob javabeen示例:ApplyNextTimeReqMsgBO

package com.yucheng.cmis.dubbo.ob; import java.io.Serializable; /**

*

申请授信时间接口javabeen:

* @author yusys

* @moduleId com.yucheng.cmis.dubbo.service * @createDate 2016-8-23 10:09:59 */

public class ApplyNextTimeReqMsgBO implements Serializable{

private static final long serialVersionUID = 1L; private String idType; //证件类型

private String idNo; //证件号码 private String loanType; //额度类型 public String getIdType() { return idType;

}

public void setIdType(String idType) { this.idType = idType; }

public String getIdNo() { return idNo;

}

public void setIdNo(String idNo) { this.idNo = idNo; }

public String getLoanType() { return loanType; }

public void setLoanType(String loanType) { this.loanType = loanType; }

public static long getSerialversionuid() { return serialVersionUID; }

}

2.3 Dubbo消费接口

消费接口流程图:

消费方调用接口时加载配制文件:applicationContextConsumer.xml所在目录:/cmismd/src/main/config/applicationContextConsumer.xml

参数解析:

dubbo:application:消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 dubbo:registry:使用注册中心暴露发现服务地址

dubbo:reference:生成远程服务代理,可以像使用本地bean一样使用demoService

每调用一个接口需要在配制文件applicationContextConsumer.xml进行配制: Demo:

消费接口开发目录结构:

Demo:

消费共用接口类:目录:/cmismd/src/main/java/com/yucheng/cmis/dubbo/service 定义接口示例:ApplyNextTimeDubboService

package com.yucheng.cmis.dubbo.service;

import com.yucheng.cmis.dubbo.ob.ApplyNextTimeReqMsgBO; import com.yucheng.cmis.dubbo.ob.ApplyNextTimeRespMsgBO; /**

*

申请授信时间接口:

* @author yusys

* @moduleId com.yucheng.cmis.dubbo.service * @createDate 2016-8-23 10:09:59 */

public interface ApplyNextTimeDubboService {

/**

* 再次申请授信时间 */

public ApplyNextTimeRespMsgBO

queryApplyNextTime(ApplyNextTimeReqMsgBO applyNextTimeReqMsgBO) throws Exception;

}

消费接口调用类:目录:/cmismd/src/main/java/com/yucheng/cmis/dubbo/connect 消费接口调用示例:ApplyNextTimeDubboConsumer

package com.yucheng.cmis.dubbo.connect; import

org.springframework.context.support.ClassPathXmlApplicationContext; import com.yucheng.cmis.dubbo.service.ApplyNextTimeDubboService; import com.yucheng.cmis.dubbo.util.DubboSpringUtil; /**

*

dubbo接口调用测试类:

* @author yusys

* @moduleId com.yucheng.cmis.dubbo.service * @createDate 2016-8-23 10:09:59 */

public class ApplyNextTimeDubboConsumer {

public static void main(String[] args) throws Exception {

ClassPathXmlApplicationContext context = new

ClassPathXmlApplicationContext( new String[]

{ \"file:D:/workspace/workspace_midea/cmis/src/main/config/applicationContextConsumer.xml\" }); context.start();

ApplyNextTimeDubboService service =

(ApplyNextTimeDubboService)DubboSpringUtil.getInstance().getBean(\"app

lyNextTimeDubboService\");

//具体调用方法 }

}

消旨接口共用javabeen:目录:/cmismd/src/main/java/com/yucheng/cmis/dubbo/ob javabeen示例:ApplyNextTimeReqMsgBO

package com.yucheng.cmis.dubbo.ob; import java.io.Serializable; /**

*

申请授信时间接口javabeen:

* @author yusys

* @moduleId com.yucheng.cmis.dubbo.service * @createDate 2016-8-23 10:09:59 */

public class ApplyNextTimeReqMsgBO implements Serializable{

private static final long serialVersionUID = 1L; private String idType; //证件类型 private String idNo; //证件号码 private String loanType; //额度类型 public String getIdType() { }

public void setIdType(String idType) { }

public String getIdNo() { }

public void setIdNo(String idNo) { }

public String getLoanType() { }

public void setLoanType(String loanType) { }

public static long getSerialversionuid() { }

return serialVersionUID; this.loanType = loanType; return loanType; this.idNo = idNo; return idNo;

this.idType = idType; return idType;

}

3. 其它项目调用接口服务

其它项目调用接口,开发时直接共用的接口包和javabeen,然后如消费接口一样在配制调用接口。具体开发过程和2.3Dubbo消费接口一致。上线时把共用接口和共用javabeen打成jar包形式使用。

因篇幅问题不能全部显示,请点此查看更多更全内容