使用dubbo将工程改造成SOA架构
来源:互联网 发布:软件外包行业分析 编辑:程序博客网 时间:2024/06/15 19:35
简述:.有两个服务,一个是web,一个是service,按道理说web是要调用service服务的,但是如果有几十个web,几十个service就会混乱,谁调用谁会出现问题的,所以使用dubbo来解决这个问题
1.使用dubbo需要在linux下布置一个注册中心,使用Zookeeper(1>可以作为集群的管理工具使用。2>可以集中管理配置文件)
简单布置步骤:
第一步:安装jdk
第二步:把zookeeper的压缩包上传到linux系统。
第三步:解压缩压缩包
tar -zxvf zookeeper-3.4.6.tar.gz
第四步:进入zookeeper-3.4.6目录,创建data文件夹。
第五步:把zoo_sample.cfg改名为zoo.cfg
[root@localhost conf]# mv zoo_sample.cfg zoo.cfg
第六步:修改data属性:dataDir=/root/zookeeper-3.4.6/data
第七步:启动zookeeper
[root@localhost bin]# ./zkServer.sh start
关闭:[root@localhost bin]# ./zkServer.sh stop
查看状态:[root@localhost bin]# ./zkServer.sh status
注意:需要关闭防火墙。
service iptables stop
永久关闭修改配置开机不启动防火墙:
chkconfig iptables off
如果不能成功启动zookeeper,需要删除data目录下的zookeeper_server.pid文件。
2.在service服务里做下面配置(pojo需要序列化 implements Serializable)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<!-- 和service相关的配置 -->
<context:component-scan base-package="com.dd.service">
</context:component-scan>
<!-- dubbos使用zookeeper发布服务 -->
<!-- 指明服务所在的工程 -->
<dubbo:application name="dd-manager"/>
<!-- 指明注册中心 -->
<dubbo:registry protocol="zookeeper" address="10.0.143.145:2181"></dubbo:registry>
<!-- 把服务暴露出去65521 -->
<dubbo:protocol name="dubbo" port="65521"></dubbo:protocol>
<!-- 指明服务接口,指明服务实例-->
<dubbo:service interface="com.dd.service.ItemService" ref="itemServiceImpl" timeout="600000"></dubbo:service>
</beans>
3.在web服务里做下面配置(pojo需要序列化implements Serializable)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<!-- 和controller相关的配置 -->
<context:component-scan base-package="com.dd.controller"></context:component-scan>
<!-- 处理器映射器,处理器适配器 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 资源映射 -->
<mvc:resources location="/WEB-INF/css/" mapping="/css/**"></mvc:resources>
<mvc:resources location="/WEB-INF/js/" mapping="/js/**"></mvc:resources>
<!-- 调用服务 -->
<!-- 指明所在的工程 -->
<dubbo:application name="dd-manager-web"/>
<!-- 指明注册中心 -->
<dubbo:registry protocol="zookeeper" address="10.0.143.145:2181" ></dubbo:registry>
<dubbo:reference interface="com.dd.service.ItemService" id="itemservice"></dubbo:reference>
</beans>
- 使用dubbo将工程改造成SOA架构
- 面试准备之SOA架构以及dubbo安装及使用
- 互联网架构 SOA(Dubbo)
- 将select改造成搜索框(chosen.jquery.js)使用
- 普通项目改造成Dubbo项目
- 将android210改造成Linux210
- 怎样将自己的工程改造成库,并上传到Github作为依赖
- 怎样将自己的工程改造成库,并上传到Github作为依赖
- 使用dubbo与zookeeper搭建面向服务的架构工程
- eclipse 使用maven 构建springboot+dubbo+zookeeper 构建soa服务(面向服务架构)
- 将PC改造成Cisco IDS
- 将无线鼠标改造成有线鼠标
- Ubuntu下将VIM改造成IDE
- 【Linux】将Vim改造成IDE
- 将vim改造成c/c++ IDE
- 将VIM改造成c++IDE
- 如何将手机改造成振动器---Vibrator
- 使用android studio将eclipse项目改造成gradle项目中踩过的坑
- 构造函数、构造代码块、和静态初始化块的执行顺序
- Js单引号转义
- 15算法课程 190. Reverse Bits
- 第一次机房收费系统-注册控件
- KB4048957引起打印机无法打印
- 使用dubbo将工程改造成SOA架构
- Django 用postman进行post请求时:Forbidden (CSRF cookie not set.) 403
- Vmware虚拟机下三种网络模式配置
- 鼠标滚轮仿星球大战文字帧动画的实现
- 字节序
- 热修复——深入浅出原理与实现
- java作业
- 只有头指针的单链表逆序
- android 公开接口收集记录