提交 1156c6f8 编写于 作者: S shenhongxi

motan

上级 03a617f9
......@@ -17,8 +17,7 @@ whatsmars-rpc 常用rpc<br />
whatsmars-spring-boot springboot果然很方便<br />
whatsmars-spring-cloud 你好,springcloud<br />
whatsmars-redis redis客户端简单封装 <br />
whatsmars-motan weibo分布式RPC框架 demo server <br />
whatsmars-motan-demo weibo分布式RPC框架 demo server&client <br />
whatsmars-motan weibo分布式RPC框架 demo <br />
# Java生态 javaeco.com
www.toutiao.im
......
......@@ -29,7 +29,6 @@
<module>rocketmq-console</module>
<module>whatsmars-redis</module>
<module>whatsmars-motan</module>
<module>whatsmars-motan-demo</module>
<module>whatsmars-spring-cloud</module>
</modules>
......
先启动zookeeper(port:2181)和whatsmars-motan
\ No newline at end of file
/**
* Created by shenhongxi on 2017/3/27.
*/
package com.itlong.motan.demo;
public interface DemoMotanService {
String hello(String name);
}
/**
* Created by shenhongxi on 2017/3/27.
*/
package com.itlong.motan.demo;
import org.springframework.stereotype.Service;
@Service("demoMotanService")
public class DemoMotanServiceImpl implements DemoMotanService {
public String hello(String name) {
System.out.println(name);
return "Hello " + name + "!";
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2009-2016 Weibo, Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:motan="http://api.weibo.com/schema/motan"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://api.weibo.com/schema/motan http://api.weibo.com/schema/motan.xsd">
<!-- 业务具体实现类 -->
<!--<bean id="demoMotanService" class="com.itlong.motan.demo.DemoMotanServiceImpl"/>-->
<!-- 协议配置。为防止多个业务配置冲突,推荐使用id表示具体协议。-->
<motan:protocol id="demoMotan" default="true" name="motan"
maxServerConnection="80000" maxContentLength="1048576"
maxWorkerThread="800" minWorkerThread="20"/>
<!-- 通用配置,多个rpc服务使用相同的基础配置. group和module定义具体的服务池。export格式为“protocol id:提供服务的端口”-->
<motan:basicService export="demoMotan:8003"
group="motan-demo-rpc" accessLog="false" shareChannel="true" module="motan-demo-rpc"
application="myMotanDemo" registry="registry" id="serviceBasicConfig"/>
<!-- 具体rpc服务配置,声明实现的接口类。-->
<motan:service interface="com.itlong.motan.demo.DemoMotanService"
ref="demoMotanService" export="demoMotan:8003" basicService="serviceBasicConfig">
</motan:service>
<motan:service interface="com.itlong.motan.demo.DemoMotanService"
ref="demoMotanService" export="demoMotan:8004" basicService="serviceBasicConfig">
</motan:service>
</beans>
......@@ -3,79 +3,26 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>whatsmars-parent</artifactId>
<groupId>com.itlong</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>whatsmars-motan</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>The demo module of motan project</description>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>com.weibo.motan.demo.service.App</start-class>
<motan.version>0.1.1</motan.version>
<skip_maven_deploy>true</skip_maven_deploy>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--weibo motan-->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-core</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-transport-netty</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-registry-consul</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-registry-zookeeper</artifactId>
<version>${motan.version}</version>
</dependency>
<!-- dependencies blow were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
<version>${motan.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<modules>
<module>whatsmars-motan-api</module>
<module>whatsmars-motan-consumer</module>
<module>whatsmars-motan-provider</module>
<module>whatsmars-motan-consumer</module>
</modules>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>whatsmars-motan</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.2.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.itlong</groupId>
<artifactId>whatsmars-motan-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo module of motan project</description>
</project>
\ No newline at end of file
......@@ -2,26 +2,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>whatsmars-motan</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.2.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>whatsmars-motan-demo</artifactId>
<artifactId>whatsmars-motan-consumer</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo module of motan project</description>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>com.itlong.motan.demo.App</start-class>
<start-class>com.weibo.motan.demo.service.App</start-class>
<motan.version>0.1.1</motan.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--weibo motan-->
<dependency>
......@@ -53,8 +55,8 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>whatsmars-motan</artifactId>
<groupId>com.itlong</groupId>
<artifactId>whatsmars-motan-api</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
</dependencies>
......
package com.itlong.motan.demo;
package com.itlong.whatsmars.motan.consumer;
import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package com.itlong.motan.demo;
package com.itlong.whatsmars.motan.consumer;
import com.weibo.motan.demo.service.MotanDemoService;
import com.itlong.whatsmars.motan.api.MotanDemoService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
......
package com.weibo.motan.demo.service;
package com.itlong.whatsmars.motan.consumer;
import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil;
......
......@@ -34,7 +34,7 @@
<!-- 具体referer配置。使用方通过beanid使用服务接口类 -->
<motan:referer id="motanDemoService"
interface="com.weibo.motan.demo.service.MotanDemoService"
interface="com.itlong.whatsmars.motan.api.MotanDemoService"
connectTimeout="300" requestTimeout="300" basicReferer="motantestClientBasicConfig"/>
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>whatsmars-motan</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.2.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>whatsmars-motan-provider</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo module of motan project</description>
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>com.itlong.whatsmars.motan.service.App</start-class>
<motan.version>0.1.1</motan.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--weibo motan-->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-core</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-transport-netty</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-registry-consul</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-registry-zookeeper</artifactId>
<version>${motan.version}</version>
</dependency>
<!-- dependencies blow were only needed for spring-based features -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
<version>${motan.version}</version>
</dependency>
<dependency>
<groupId>com.itlong</groupId>
<artifactId>whatsmars-motan-api</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.weibo.motan.demo.service;
package com.itlong.whatsmars.motan.service;
import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package com.itlong.motan.demo;
package com.itlong.whatsmars.motan.service;
import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil;
......
......@@ -14,9 +14,9 @@
* limitations under the License.
*/
package com.weibo.motan.demo.service.impl;
package com.itlong.whatsmars.motan.service.impl;
import com.weibo.motan.demo.service.MotanDemoService;
import com.itlong.whatsmars.motan.api.MotanDemoService;
import org.springframework.stereotype.Service;
@Service("motanDemoService")
......
......@@ -40,10 +40,10 @@
application="myMotanDemo" registry="registry" id="serviceBasicConfig"/>
<!-- 具体rpc服务配置,声明实现的接口类。-->
<motan:service interface="com.weibo.motan.demo.service.MotanDemoService"
<motan:service interface="com.itlong.whatsmars.motan.api.MotanDemoService"
ref="motanDemoService" export="demoMotan:8001" basicService="serviceBasicConfig">
</motan:service>
<motan:service interface="com.weibo.motan.demo.service.MotanDemoService"
<motan:service interface="com.itlong.whatsmars.motan.api.MotanDemoService"
ref="motanDemoService" export="demoMotan:8002" basicService="serviceBasicConfig">
</motan:service>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册