Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

新增dubbo2的samples #248

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion samples/dubbo-samples/rpc/dubbo26/dubbo26base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<artifactId>log4j-to-slf4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -99,7 +113,7 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<mainClass>com.alipay.sofa.rpc.dubbo26.base.BaseApplication</mainClass>
<mainClass>com.alipay.sofa.rpc.dubbo26.base.Dubbo26BaseApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;

/**
*
Expand All @@ -21,8 +22,9 @@
*/

@SpringBootApplication
public class BaseApplication implements CommandLineRunner {
private static Logger LOGGER = LoggerFactory.getLogger(BaseApplication.class);
@ImportResource("classpath:provider.xml")
public class Dubbo26BaseApplication implements CommandLineRunner {
private static Logger LOGGER = LoggerFactory.getLogger(Dubbo26BaseApplication.class);

public static void main(String[] args) {

Expand All @@ -34,7 +36,7 @@ public static void main(String[] args) {
System.setProperty("sofa.ark.embed.enable", "true");
System.setProperty("sofa.ark.plugin.export.class.enable", "true");

SpringApplication.run(BaseApplication.class, args);
SpringApplication.run(Dubbo26BaseApplication.class, args);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Ant Group
* Copyright (c) 2004-2023 All Rights Reserved.
*/
package com.alipay.sofa.rpc.dubbo26.base.service;

import com.alipay.sofa.rpc.dubbo26.model.DemoRequest;
import com.alipay.sofa.rpc.dubbo26.model.DemoResponse;
import com.alipay.sofa.rpc.dubbo26.model.DemoService;

/**
*
* @author syd
* @version BaseDemoService.java, v 0.1 2023年11月06日 12:21 syd
*/
public class BaseDemoService implements DemoService {

@Override
public DemoResponse handle(DemoRequest demoRequest) {
DemoResponse response = new DemoResponse();
response.setResult(demoRequest.getBiz() + "->" + getClass().getName());
return response;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT-APPENDER" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p %c{2} - %m%n%throwable" charset="UTF-8"/>
</Console>

<Console name="STDERR-APPENDER" target="SYSTEM_ERR">
<PatternLayout pattern="%-5p %c{2} - %m%n%throwable" charset="UTF-8"/>
</Console>

<RollingFile name="ERROR-APPENDER"
fileName="${ctx:logging.file.path}/${ctx:spring.application.name}/common-error.log"
filePattern="${ctx:logging.file.path}/${ctx:spring.application.name}/common-error.log.%d{yyyy-MM-dd}"
append="true">
<PatternLayout
pattern="%d [%X{traceId} %X{rpcId} - %X{loginUserEmail}/%X{loginUserID}/%X{remoteAddr}/%X{clientId} - %X{requestURIWithQueryString}] %-5p %c{2} - %m%n%throwable"
charset="UTF-8"/>
<TimeBasedTriggeringPolicy/>
<DefaultRolloverStrategy/>
<ThresholdFilter level="ERROR"/>
</RollingFile>

<RollingFile name="WARN-APPENDER"
fileName="${ctx:logging.file.path}/${ctx:spring.application.name}/common-warn.log"
filePattern="${ctx:logging.file.path}/${ctx:spring.application.name}/common-warn.log.%d{yyyy-MM-dd}"
append="true">
<PatternLayout
pattern="%d [%X{traceId} %X{rpcId} - %X{loginUserEmail}/%X{loginUserID}/%X{remoteAddr}/%X{clientId} - %X{requestURIWithQueryString}] %-5p %c{2} - %m%n%throwable"
charset="UTF-8"/>
<TimeBasedTriggeringPolicy/>
<DefaultRolloverStrategy/>
<Filters>
<ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>

<RollingFile name="APP-DEFAULT-APPENDER"
fileName="${ctx:logging.file.path}/${ctx:spring.application.name}/app-default.log"
filePattern="${ctx:logging.file.path}/${ctx:spring.application.name}/app-default.log.%d{yyyy-MM-dd-HH}"
append="true">
<PatternLayout
pattern="%d [%X{traceId} %X{rpcId} - %X{loginUserEmail}/%X{loginUserID}/%X{remoteAddr}/%X{clientId} - %X{requestURIWithQueryString}] %-5p %c{2} - %m%n%throwable"
charset="UTF-8"/>
<TimeBasedTriggeringPolicy/>
<DefaultRolloverStrategy/>
</RollingFile>

<RollingFile name="SPRING-APPENDER" fileName="${ctx:logging.file.path}/spring/spring.log"
filePattern="${ctx:logging.file.path}/spring/spring.log.%d{yyyy-MM-dd}"
append="true">
<PatternLayout
pattern="%d [%X{traceId} %X{rpcId} - %X{loginUserEmail}/%X{loginUserID}/%X{remoteAddr}/%X{clientId} - %X{requestURIWithQueryString}] %-5p %c{2} - %m%n%throwable"
charset="UTF-8"/>
<TimeBasedTriggeringPolicy/>
<DefaultRolloverStrategy/>
</RollingFile>

<RollingFile name="NO-USAGE-APPENDER" fileName="${ctx:logging.file.path}/no-usage/no-usage.log"
filePattern="${ctx:logging.file.path}/no-usage/no-usage.log.%d{yyyy-MM-dd}"
append="true">
<PatternLayout
pattern="%d [%X{traceId} %X{rpcId} - %X{loginUserEmail}/%X{loginUserID}/%X{remoteAddr}/%X{clientId} - %X{requestURIWithQueryString}] %-5p %c{2} - %m%n%throwable"
charset="UTF-8"/>
<TimeBasedTriggeringPolicy/>
<DefaultRolloverStrategy/>
</RollingFile>
</Appenders>

<Loggers>
<AsyncLogger name="STDOUT" additivity="false" level="info">
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>

<AsyncLogger name="STDERR" additivity="false" level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo26}">
<AppenderRef ref="STDERR-APPENDER"/>
</AsyncLogger>

<AsyncLogger name="com.alipay.sofa.rpc.dubbo26" additivity="false" level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo26}">
<AppenderRef ref="APP-DEFAULT-APPENDER"/>
<AppenderRef ref="WARN-APPENDER"/>
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>

<AsyncLogger name="org.springframework" additivity="false"
level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo26}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="WARN-APPENDER"/>
<AppenderRef ref="SPRING-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>

<AsyncRoot level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo26}">
<AppenderRef ref="APP-DEFAULT-APPENDER"/>
<AppenderRef ref="WARN-APPENDER"/>
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncRoot>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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:dubbo="http://dubbo.apache.org/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">

<!-- 使用multicast广播注册中心暴露服务地址 -->
<dubbo:registry address="multicast://224.5.6.7:1234"/>

<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" serialization="java"/>

<!-- 和本地bean一样实现服务 -->
<bean id="demoService" class="com.alipay.sofa.rpc.dubbo26.base.service.BaseDemoService"/>
<!-- 声明需要暴露的服务接口 -->
<dubbo:service interface="com.alipay.sofa.rpc.dubbo26.model.DemoService" ref="demoService" group="base"/> <!-- 和本地bean一样实现服务 -->

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class BizController {

@Resource
private HelloService helloServiceRef;
@Resource
private DemoService baseDemoServiceRef;

@Autowired
private ApplicationContext applicationContext;
Expand All @@ -62,6 +64,15 @@ public HelloResponse hello(String name) {
return helloServiceRef.sayHello(helloRequest);
}

@RequestMapping(value = "/base", method = RequestMethod.GET)
@ResponseBody
public DemoResponse base(String ref) {
String appName = applicationContext.getId();
DemoRequest demoRequest = new DemoRequest();
demoRequest.setBiz(appName);
return baseDemoServiceRef.handle(demoRequest);
}

public void setDemoServiceRef(DemoService demoServiceRef) {
this.demoServiceRef = demoServiceRef;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
<dubbo:reference id="demoServiceRef" interface="com.alipay.sofa.rpc.dubbo26.model.DemoService" scope="remote" group="biz2" check="false"/>
<dubbo:reference id="secondDemoServiceRef" interface="com.alipay.sofa.rpc.dubbo26.model.DemoService" scope="remote" group="biz2" check="false"/>
<dubbo:reference id="helloServiceRef" interface="com.alipay.sofa.rpc.dubbo26.model.HelloService" scope="remote" group="biz2" check="false"/>
<dubbo:reference id="baseDemoServiceRef" interface="com.alipay.sofa.rpc.dubbo26.model.DemoService" scope="local" group="base" check="false"/>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>

<AsyncLogger name="STDERR" additivity="false" level="${ctx:logging.level.com.alipay.sofa.rpc.grpc}">
<AsyncLogger name="STDERR" additivity="false" level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo3}">
<AppenderRef ref="STDERR-APPENDER"/>
</AsyncLogger>

<AsyncLogger name="com.alipay.sofa.rpc.grpc" additivity="false" level="${ctx:logging.level.com.alipay.sofa.rpc.grpc}">
<AsyncLogger name="com.alipay.sofa.rpc.dubbo3" additivity="false" level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo3}">
<AppenderRef ref="APP-DEFAULT-APPENDER"/>
<AppenderRef ref="WARN-APPENDER"/>
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>

<AsyncLogger name="org.springframework" additivity="false"
level="${ctx:logging.level.com.alipay.sofa.rpc.grpc}">
level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo3}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="WARN-APPENDER"/>
<AppenderRef ref="SPRING-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>

<AsyncRoot level="${ctx:logging.level.com.alipay.sofa.rpc.grpc}">
<AsyncRoot level="${ctx:logging.level.com.alipay.sofa.rpc.dubbo3}">
<AppenderRef ref="APP-DEFAULT-APPENDER"/>
<AppenderRef ref="WARN-APPENDER"/>
<AppenderRef ref="ERROR-APPENDER"/>
Expand Down
2 changes: 1 addition & 1 deletion samples/dubbo-samples/rpc/dubbo3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dubbo.version>2.6.4</dubbo.version>
<spring.boot.version>2.7.16</spring.boot.version>
<sofa.ark.version>2.2.4-SNAPSHOT</sofa.ark.version>
<sofa.serverless.runtime.version>0.5.0</sofa.serverless.runtime.version>
<sofa.serverless.runtime.version>0.5.1</sofa.serverless.runtime.version>
<disruptor.version>3.4.2</disruptor.version>
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
<dubbo.version>3.1.11</dubbo.version>
Expand Down
1 change: 0 additions & 1 deletion samples/dubbo-samples/rpc/dubbo3/triplebiz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<groupId>com.alipay.sofa</groupId>
<artifactId>common-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down