Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jeecg
jeecg-boot
提交
eb1578ad
J
jeecg-boot
项目概览
jeecg
/
jeecg-boot
上一次同步 3 年多
通知
863
Star
24375
Fork
84
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jeecg-boot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eb1578ad
编写于
2月 21, 2021
作者:
JEECG低代码平台
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
删除jeecg-cloud-example例子模块,测试示例重构到jeecg-cloud-system-start中---
上级
90758f3b
变更
21
显示空白变更内容
内联
并排
Showing
21 changed file
with
177 addition
and
237 deletion
+177
-237
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/Dockerfile
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/Dockerfile
+0
-16
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/pom.xml
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/pom.xml
+0
-53
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/java/org/jeecg/JeecgCloudExampleApplication.java
...src/main/java/org/jeecg/JeecgCloudExampleApplication.java
+0
-17
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/java/org/jeecg/cloud/demo/rabbitmq/DemoRabbitMqListener2.java
.../org/jeecg/cloud/demo/rabbitmq/DemoRabbitMqListener2.java
+0
-28
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/java/org/jeecg/cloud/demo/test/service/impl/JeecgDemoServiceImpl.java
...cg/cloud/demo/test/service/impl/JeecgDemoServiceImpl.java
+0
-13
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/resources/application.yml
...le/jeecg-cloud-example/src/main/resources/application.yml
+0
-5
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/pom.xml
...-boot/jeecg-cloud-module/jeecg-cloud-system-start/pom.xml
+13
-6
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java
.../src/main/java/org/jeecg/JeecgSystemCloudApplication.java
+3
-4
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/constant/CloudConstant.java
.../java/org/jeecg/modules/cloud/constant/CloudConstant.java
+30
-0
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/ebus/DemoBusEvent.java
.../main/java/org/jeecg/modules/cloud/ebus/DemoBusEvent.java
+3
-2
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/controller/JeecgTestFeignController.java
...ules/cloud/feign/controller/JeecgTestFeignController.java
+61
-0
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/JeecgTestClient.java
.../org/jeecg/modules/cloud/feign/feign/JeecgTestClient.java
+3
-1
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/JeecgTestClientDyn.java
...g/jeecg/modules/cloud/feign/feign/JeecgTestClientDyn.java
+1
-1
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/fallback/JeecgTestClientFallback.java
...s/cloud/feign/feign/fallback/JeecgTestClientFallback.java
+3
-2
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/lock/DemoLockTest.java
.../main/java/org/jeecg/modules/cloud/lock/DemoLockTest.java
+22
-18
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver1.java
...java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver1.java
+9
-2
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver2.java
...java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver2.java
+9
-2
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver3.java
...java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver3.java
+13
-7
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloTimeReceiver.java
...a/org/jeecg/modules/cloud/rabbitmq/HelloTimeReceiver.java
+5
-2
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/xxljob/Demo2JobHandler.java
.../java/org/jeecg/modules/cloud/xxljob/Demo2JobHandler.java
+0
-57
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/xxljob/DemoJobHandler.java
...n/java/org/jeecg/modules/cloud/xxljob/DemoJobHandler.java
+2
-1
未找到文件。
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/Dockerfile
已删除
100644 → 0
浏览文件 @
90758f3b
FROM
anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER
jeecgos@163.com
RUN
ln
-sf
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN
mkdir
-p
/jeecg-cloud-example
WORKDIR
/jeecg-cloud-example
EXPOSE
7001
ADD
./target/jeecg-cloud-example-2.4.2.jar ./
CMD
java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-example-2.4.2.jar
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/pom.xml
已删除
100644 → 0
浏览文件 @
90758f3b
<?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>
jeecg-cloud-module
</artifactId>
<groupId>
org.jeecgframework.boot
</groupId>
<version>
2.4.2
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
jeecg-cloud-example
</artifactId>
<description>
jeecg-cloud-example 微服务测试例子
</description>
<dependencies>
<!-- 引入jeecg-boot-starter-cloud依赖-->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-starter-cloud
</artifactId>
</dependency>
<!-- 引入定时任务依赖 -->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-starter-job
</artifactId>
</dependency>
<!-- 引入分布式锁依赖 -->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-starter-lock
</artifactId>
</dependency>
<!--rabbitmq消息队列-->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-starter-rabbitmq
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
true
</filtering>
</resource>
</resources>
</build>
</project>
\ No newline at end of file
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/java/org/jeecg/JeecgCloudExampleApplication.java
已删除
100644 → 0
浏览文件 @
90758f3b
package
org.jeecg
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@EnableScheduling
@EnableFeignClients
(
basePackages
=
{
"org.jeecg"
})
@SpringBootApplication
(
scanBasePackages
=
"org.jeecg"
)
public
class
JeecgCloudExampleApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
JeecgCloudExampleApplication
.
class
,
args
);
}
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/java/org/jeecg/cloud/demo/rabbitmq/DemoRabbitMqListener2.java
已删除
100644 → 0
浏览文件 @
90758f3b
package
org.jeecg.cloud.demo.rabbitmq
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler
;
import
org.jeecg.boot.starter.rabbitmq.listenter.MqListener
;
import
org.jeecg.common.annotation.RabbitComponent
;
import
org.jeecg.common.base.BaseMap
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.support.AmqpHeaders
;
import
org.springframework.messaging.handler.annotation.Header
;
@Slf4j
@RabbitComponent
(
value
=
"testListener2"
)
public
class
DemoRabbitMqListener2
extends
BaseRabbiMqHandler
<
BaseMap
>
{
@RabbitListener
(
queues
=
"test2"
)
public
void
onMessage
(
BaseMap
baseMap
,
Channel
channel
,
@Header
(
AmqpHeaders
.
DELIVERY_TAG
)
long
deliveryTag
)
{
super
.
onMessage
(
baseMap
,
deliveryTag
,
channel
,
new
MqListener
<
BaseMap
>()
{
@Override
public
void
handler
(
BaseMap
map
,
Channel
channel
)
{
String
orderId
=
map
.
get
(
"orderId"
);
log
.
info
(
"业务处理2:orderId:"
+
orderId
);
}
});
}
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/java/org/jeecg/cloud/demo/test/service/impl/JeecgDemoServiceImpl.java
已删除
100644 → 0
浏览文件 @
90758f3b
package
org.jeecg.cloud.demo.test.service.impl
;
import
org.jeecg.cloud.demo.test.service.JeecgDemoService
;
import
org.jeecg.common.api.vo.Result
;
import
org.springframework.stereotype.Service
;
@Service
public
class
JeecgDemoServiceImpl
implements
JeecgDemoService
{
@Override
public
Result
<
String
>
getMessage
(
String
name
)
{
return
Result
.
OK
(
"Hello"
+
name
);
}
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-example/src/main/resources/application.yml
已删除
100644 → 0
浏览文件 @
90758f3b
server
:
port
:
7003
spring
:
application
:
name
:
jeecg-cloud-example
\ No newline at end of file
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/pom.xml
浏览文件 @
eb1578ad
...
...
@@ -9,14 +9,9 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
jeecg-cloud-system-start
</artifactId>
<description>
jeecg-cloud-system-start基础启动模块
</description>
<description>
System项目微服务启动
</description>
<dependencies>
<!-- 引入jeecg-boot-module-system依赖 -->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-module-system
</artifactId>
</dependency>
<!-- 引入jeecg-boot-starter-cloud依赖 -->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
...
...
@@ -29,6 +24,12 @@
</exclusion>
</exclusions>
</dependency>
<!-- 引入jeecg-boot-module-system依赖 -->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-module-system
</artifactId>
</dependency>
<!--rabbitmq消息队列-->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
...
...
@@ -39,6 +40,12 @@
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-starter-job
</artifactId>
</dependency>
<!-- 分布式锁依赖 -->
<dependency>
<groupId>
org.jeecgframework.boot
</groupId>
<artifactId>
jeecg-boot-starter-lock
</artifactId>
</dependency>
</dependencies>
<build>
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java
浏览文件 @
eb1578ad
package
org.jeecg
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.catalina.Context
;
import
org.apache.tomcat.util.scan.StandardJarScanner
;
import
org.jeecg.common.util.oConvertUtils
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
...
...
@@ -24,6 +21,7 @@ import java.net.UnknownHostException;
@Slf4j
@SpringBootApplication
@EnableFeignClients
(
basePackages
=
{
"org.jeecg"
})
@EnableScheduling
public
class
JeecgSystemCloudApplication
extends
SpringBootServletInitializer
{
@Override
...
...
@@ -45,4 +43,5 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer {
"----------------------------------------------------------"
);
}
}
\ No newline at end of file
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/constant/CloudConstant.java
0 → 100644
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.constant
;
/**
* 微服务单元测试常量定义
*/
public
interface
CloudConstant
{
/**
* 微服务名【对应模块jeecg-boot-module-demo】
*/
public
final
static
String
SERVER_NAME_JEECGDEMO
=
"jeecg-demo"
;
/**
* MQ测试队列名字
*/
public
final
static
String
MQ_JEECG_PLACE_ORDER
=
"jeecg_place_order"
;
public
final
static
String
MQ_JEECG_PLACE_ORDER_TIME
=
"jeecg_place_order_time"
;
/**
* MQ测试消息总线
*/
public
final
static
String
MQ_DEMO_BUS_EVENT
=
"demoBusEvent"
;
/**
* 分布式锁lock key
*/
public
final
static
String
REDISSON_DEMO_LOCK_KEY1
=
"demoLockKey1"
;
public
final
static
String
REDISSON_DEMO_LOCK_KEY2
=
"demoLockKey2"
;
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
example/src/main/java/org/jeecg/cloud/demo/
bus/DemoBusEvent.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
system-start/src/main/java/org/jeecg/modules/cloud/e
bus/DemoBusEvent.java
浏览文件 @
eb1578ad
package
org.jeecg.
cloud.demo.
bus
;
package
org.jeecg.
modules.cloud.e
bus
;
import
cn.hutool.core.util.ObjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecg.boot.starter.rabbitmq.event.EventObj
;
import
org.jeecg.boot.starter.rabbitmq.event.JeecgBusEventHandler
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.springframework.stereotype.Component
;
/**
* 消息处理器【发布订阅】
*/
@Slf4j
@Component
(
"demoBusEvent"
)
@Component
(
CloudConstant
.
MQ_DEMO_BUS_EVENT
)
public
class
DemoBusEvent
implements
JeecgBusEventHandler
{
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/controller/JeecgTestFeign
Test
.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/controller/JeecgTestFeign
Controller
.java
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.feign.controller
;
import
cn.hutool.core.util.RandomUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.jeecg.boot.starter.rabbitmq.client.RabbitMqClient
;
import
org.jeecg.common.api.vo.Result
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.jeecg.modules.cloud.feign.feign.JeecgTestClient
;
import
org.jeecg.modules.cloud.feign.feign.JeecgTestClient
2
;
import
org.jeecg.modules.cloud.feign.feign.JeecgTestClient
Dyn
;
import
org.jeecg.starter.cloud.feign.impl.JeecgFeignService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
@RequestMapping
(
"/sys/test"
)
@Api
(
tags
=
"
feign
测试"
)
public
class
JeecgTestFeign
Test
{
@Api
(
tags
=
"
【微服务】单元
测试"
)
public
class
JeecgTestFeign
Controller
{
@Autowired
private
JeecgFeignService
jeecgFeignService
;
@Autowired
private
JeecgTestClient
jeecgTestClient
;
@Autowired
private
RabbitMqClient
rabbitMqClient
;
@GetMapping
(
"getMessage"
)
@ApiOperation
(
value
=
"测试feign"
,
notes
=
"测试feign"
)
...
...
@@ -33,7 +39,23 @@ public class JeecgTestFeignTest {
@GetMapping
(
"getMessage2"
)
@ApiOperation
(
value
=
"测试动态feign"
,
notes
=
"测试动态feign"
)
public
Result
<
String
>
getMessage2
()
{
JeecgTestClient2
jeecgTestClient
=
jeecgFeignService
.
newInstance
(
JeecgTestClient2
.
class
,
"jeecg-demo"
);
return
jeecgTestClient
.
getMessage
(
"jeecg-boot2"
);
JeecgTestClientDyn
myClientDyn
=
jeecgFeignService
.
newInstance
(
JeecgTestClientDyn
.
class
,
CloudConstant
.
SERVER_NAME_JEECGDEMO
);
return
myClientDyn
.
getMessage
(
"动态fegin——jeecg-boot2"
);
}
@GetMapping
(
value
=
"/rabbitmq"
)
@ApiOperation
(
value
=
"测试rabbitmq"
,
notes
=
"测试rabbitmq"
)
public
Result
<?>
rabbitMqClientTest
(
HttpServletRequest
req
)
{
//rabbitmq消息队列测试
BaseMap
map
=
new
BaseMap
();
map
.
put
(
"orderId"
,
RandomUtil
.
randomNumbers
(
10
));
rabbitMqClient
.
sendMessage
(
CloudConstant
.
MQ_JEECG_PLACE_ORDER
,
map
);
rabbitMqClient
.
sendMessage
(
CloudConstant
.
MQ_JEECG_PLACE_ORDER_TIME
,
map
,
10
);
//rabbitmq消息总线测试
BaseMap
params
=
new
BaseMap
();
params
.
put
(
"orderId"
,
"123456"
);
rabbitMqClient
.
publishEvent
(
CloudConstant
.
MQ_DEMO_BUS_EVENT
,
params
);
return
Result
.
OK
(
"MQ发送消息成功"
);
}
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/JeecgTestClient.java
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.feign.feign
;
import
org.jeecg.common.api.vo.Result
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.jeecg.modules.cloud.feign.feign.fallback.JeecgTestClientFallback
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -9,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* 常规feign接口定义
*/
@FeignClient
(
value
=
"jeecg-demo"
,
fallbackFactory
=
Demo
Fallback
.
class
)
@FeignClient
(
value
=
CloudConstant
.
SERVER_NAME_JEECGDEMO
,
fallbackFactory
=
JeecgTestClient
Fallback
.
class
)
@Component
public
interface
JeecgTestClient
{
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/JeecgTestClient
2
.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/JeecgTestClient
Dyn
.java
浏览文件 @
eb1578ad
...
...
@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* 动态feign接口定义
*/
public
interface
JeecgTestClient
2
{
public
interface
JeecgTestClient
Dyn
{
@GetMapping
(
value
=
"/test/getMessage"
)
Result
<
String
>
getMessage
(
@RequestParam
(
"name"
)
String
name
);
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/
Demo
Fallback.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/feign/feign/
fallback/JeecgTestClient
Fallback.java
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.feign.feign
;
package
org.jeecg.modules.cloud.feign.feign
.fallback
;
import
feign.hystrix.FallbackFactory
;
import
org.jeecg.modules.cloud.feign.feign.JeecgTestClient
;
import
org.springframework.stereotype.Component
;
/**
* @author qinfeng
*/
@Component
public
class
Demo
Fallback
implements
FallbackFactory
<
JeecgTestClient
>
{
public
class
JeecgTestClient
Fallback
implements
FallbackFactory
<
JeecgTestClient
>
{
@Override
public
JeecgTestClient
create
(
Throwable
throwable
)
{
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
example/src/main/java/org/jeecg/cloud/demo
/lock/DemoLockTest.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
system-start/src/main/java/org/jeecg/modules/cloud
/lock/DemoLockTest.java
浏览文件 @
eb1578ad
package
org.jeecg.
cloud.demo
.lock
;
package
org.jeecg.
modules.cloud
.lock
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecg.boot.starter.lock.annotation.DistributedLock
;
import
org.jeecg.boot.starter.lock.client.RedissonLockClient
;
import
org.jeecg.boot.starter.rabbitmq.client.RabbitMqClient
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -19,43 +21,45 @@ import java.util.Map;
public
class
DemoLockTest
{
@Autowired
RedissonLockClient
redissonLock
;
@Autowired
RabbitMqClient
rabbitMqClient
;
/**
*
注解方式测试分布式锁
*
测试分布式锁【注解方式】
*/
//
@Scheduled(cron = "0/5 * * * * ?")
@DistributedLock
(
lockKey
=
"redis-lock"
,
expireSeconds
=
1
1
)
@Scheduled
(
cron
=
"0/5 * * * * ?"
)
@DistributedLock
(
lockKey
=
CloudConstant
.
REDISSON_DEMO_LOCK_KEY
1
)
public
void
execute
()
throws
InterruptedException
{
log
.
info
(
"执行execute任务开始,休眠三秒"
);
Thread
.
sleep
(
3000
);
System
.
out
.
println
(
"=======================业务逻辑1============================="
);
Map
map
=
new
Hash
Map
();
map
.
put
(
"orderId"
,
"
12345
"
);
rabbitMqClient
.
sendMessage
(
"test"
,
map
);
Map
map
=
new
Base
Map
();
map
.
put
(
"orderId"
,
"
BJ0001
"
);
rabbitMqClient
.
sendMessage
(
CloudConstant
.
MQ_JEECG_PLACE_ORDER
,
map
);
//延迟10秒发送
map
.
put
(
"orderId"
,
"
555555
"
);
rabbitMqClient
.
sendMessage
(
"test"
,
map
,
10000
);
map
.
put
(
"orderId"
,
"
NJ0002
"
);
rabbitMqClient
.
sendMessage
(
CloudConstant
.
MQ_JEECG_PLACE_ORDER
,
map
,
10000
);
log
.
info
(
"execute任务结束,休眠三秒"
);
}
public
DemoLockTest
()
{
}
/**
*
编码方式测试分布式锁
*
测试分布式锁【编码方式】
*/
//@Scheduled(cron = "0/
10
* * * * ?")
//@Scheduled(cron = "0/
5
* * * * ?")
public
void
execute2
()
throws
InterruptedException
{
if
(
redissonLock
.
tryLock
(
"redisson"
,
-
1
,
1
0
))
{
log
.
info
(
"执行任务execute2开始,休眠
三
秒"
);
Thread
.
sleep
(
3
000
);
if
(
redissonLock
.
tryLock
(
CloudConstant
.
REDISSON_DEMO_LOCK_KEY2
,
-
1
,
600
0
))
{
log
.
info
(
"执行任务execute2开始,休眠
十
秒"
);
Thread
.
sleep
(
10
000
);
System
.
out
.
println
(
"=======================业务逻辑2============================="
);
log
.
info
(
"定时execute2结束,休眠三秒"
);
redissonLock
.
unlock
(
"redisson"
);
log
.
info
(
"定时execute2结束,休眠十秒"
);
redissonLock
.
unlock
(
CloudConstant
.
REDISSON_DEMO_LOCK_KEY2
);
}
else
{
log
.
info
(
"execute2获取锁失败"
);
}
}
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver1.java
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.rabbitmq
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler
;
import
org.jeecg.boot.starter.rabbitmq.listenter.MqListener
;
import
org.jeecg.common.annotation.RabbitComponent
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.support.AmqpHeaders
;
import
org.springframework.messaging.handler.annotation.Header
;
@RabbitListener
(
queues
=
"jeecg_place_order"
)
/**
* RabbitMq接受者1
* (@RabbitListener声明类上,一个类只能监听一个队列)
*/
@Slf4j
@RabbitListener
(
queues
=
CloudConstant
.
MQ_JEECG_PLACE_ORDER
)
@RabbitComponent
(
value
=
"helloReceiver1"
)
public
class
HelloReceiver1
extends
BaseRabbiMqHandler
<
BaseMap
>
{
...
...
@@ -21,7 +28,7 @@ public class HelloReceiver1 extends BaseRabbiMqHandler<BaseMap> {
public
void
handler
(
BaseMap
map
,
Channel
channel
)
{
//业务处理
String
orderId
=
map
.
get
(
"orderId"
).
toString
();
System
.
out
.
println
(
"Receiver1
: "
+
orderId
);
log
.
info
(
"MQ Receiver1,orderId
: "
+
orderId
);
}
});
}
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloReceiver2.java
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.rabbitmq
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler
;
import
org.jeecg.boot.starter.rabbitmq.listenter.MqListener
;
import
org.jeecg.common.annotation.RabbitComponent
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.support.AmqpHeaders
;
import
org.springframework.messaging.handler.annotation.Header
;
@RabbitListener
(
queues
=
"jeecg_place_order"
)
/**
* RabbitMq接受者2
* (@RabbitListener声明类上,一个类只能监听一个队列)
*/
@Slf4j
@RabbitListener
(
queues
=
CloudConstant
.
MQ_JEECG_PLACE_ORDER
)
@RabbitComponent
(
value
=
"helloReceiver2"
)
public
class
HelloReceiver2
extends
BaseRabbiMqHandler
<
BaseMap
>
{
...
...
@@ -21,7 +28,7 @@ public class HelloReceiver2 extends BaseRabbiMqHandler<BaseMap> {
public
void
handler
(
BaseMap
map
,
Channel
channel
)
{
//业务处理
String
orderId
=
map
.
get
(
"orderId"
).
toString
();
System
.
out
.
println
(
"Receiver2
: "
+
orderId
);
log
.
info
(
"MQ Receiver2,orderId
: "
+
orderId
);
}
});
}
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
example/src/main/java/org/jeecg/cloud/demo/rabbitmq/DemoRabbitMqListen
er3.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloReceiv
er3.java
浏览文件 @
eb1578ad
package
org.jeecg.
cloud.demo
.rabbitmq
;
package
org.jeecg.
modules.cloud
.rabbitmq
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -6,24 +6,30 @@ import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
import
org.jeecg.boot.starter.rabbitmq.listenter.MqListener
;
import
org.jeecg.common.annotation.RabbitComponent
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.support.AmqpHeaders
;
import
org.springframework.messaging.handler.annotation.Header
;
/**
* RabbitMq接受者3
* (@RabbitListener声明类方法上,一个类可以多监听多个队列)
*/
@Slf4j
@RabbitListener
(
queues
=
"test3"
)
@RabbitComponent
(
value
=
"testListener3"
)
public
class
DemoRabbitMqListener3
extends
BaseRabbiMqHandler
<
BaseMap
>
{
@RabbitComponent
(
value
=
"helloReceiver3"
)
public
class
HelloReceiver3
extends
BaseRabbiMqHandler
<
BaseMap
>
{
@Rabbit
Handler
@Rabbit
Listener
(
queues
=
CloudConstant
.
MQ_JEECG_PLACE_ORDER
)
public
void
onMessage
(
BaseMap
baseMap
,
Channel
channel
,
@Header
(
AmqpHeaders
.
DELIVERY_TAG
)
long
deliveryTag
)
{
super
.
onMessage
(
baseMap
,
deliveryTag
,
channel
,
new
MqListener
<
BaseMap
>()
{
@Override
public
void
handler
(
BaseMap
map
,
Channel
channel
)
{
//业务处理
String
orderId
=
map
.
get
(
"orderId"
).
toString
();
log
.
info
(
"
业务处理3:orderId:
"
+
orderId
);
log
.
info
(
"
MQ Receiver3,orderId :
"
+
orderId
);
}
});
}
}
\ No newline at end of file
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/rabbitmq/HelloTimeReceiver.java
浏览文件 @
eb1578ad
package
org.jeecg.modules.cloud.rabbitmq
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler
;
import
org.jeecg.boot.starter.rabbitmq.listenter.MqListener
;
import
org.jeecg.common.annotation.RabbitComponent
;
import
org.jeecg.common.base.BaseMap
;
import
org.jeecg.modules.cloud.constant.CloudConstant
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.amqp.support.AmqpHeaders
;
import
org.springframework.messaging.handler.annotation.Header
;
@RabbitListener
(
queues
=
"jeecg_place_order_time"
)
@Slf4j
@RabbitListener
(
queues
=
CloudConstant
.
MQ_JEECG_PLACE_ORDER_TIME
)
@RabbitComponent
(
value
=
"helloTimeReceiver"
)
public
class
HelloTimeReceiver
extends
BaseRabbiMqHandler
<
BaseMap
>
{
...
...
@@ -21,7 +24,7 @@ public class HelloTimeReceiver extends BaseRabbiMqHandler<BaseMap> {
public
void
handler
(
BaseMap
map
,
Channel
channel
)
{
//业务处理
String
orderId
=
map
.
get
(
"orderId"
).
toString
();
System
.
out
.
println
(
"Receiver1
: "
+
orderId
);
log
.
info
(
"Time Receiver1,orderId
: "
+
orderId
);
}
});
}
...
...
jeecg-boot/jeecg-cloud-module/jeecg-cloud-system-start/src/main/java/org/jeecg/modules/cloud/xxljob/Demo2JobHandler.java
已删除
100644 → 0
浏览文件 @
90758f3b
package
org.jeecg.modules.cloud.xxljob
;;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.annotation.XxlJob
;
import
com.xxl.job.core.log.XxlJobLogger
;
import
com.xxl.job.core.util.ShardingUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
/**
* xxl-job定时任务测试
*/
@Component
@Slf4j
public
class
Demo2JobHandler
{
/**
* 简单任务
*
* @param params
* @return
*/
@XxlJob
(
value
=
"demoJob2"
)
public
ReturnT
<
String
>
demoJobHandler
(
String
params
)
{
log
.
info
(
"我是定时任务,我执行了..............................."
);
return
ReturnT
.
SUCCESS
;
}
/**
* 2、分片广播任务
*/
@XxlJob
(
"shardingJobHandler3"
)
public
ReturnT
<
String
>
shardingJobHandler
(
String
param
)
throws
Exception
{
// 分片参数
ShardingUtil
.
ShardingVO
shardingVO
=
ShardingUtil
.
getShardingVo
();
XxlJobLogger
.
log
(
"分片参数:当前分片序号 = {}, 总分片数 = {}"
,
shardingVO
.
getIndex
(),
shardingVO
.
getTotal
());
// 业务逻辑
for
(
int
i
=
0
;
i
<
shardingVO
.
getTotal
();
i
++)
{
if
(
i
==
shardingVO
.
getIndex
())
{
XxlJobLogger
.
log
(
"第 {} 片, 命中分片开始处理"
,
i
);
}
else
{
XxlJobLogger
.
log
(
"第 {} 片, 忽略"
,
i
);
}
}
return
ReturnT
.
SUCCESS
;
}
}
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
example/src/main/java/org/jeecg/cloud/demo/
job/DemoJobHandler.java
→
jeecg-boot/jeecg-cloud-module/jeecg-cloud-
system-start/src/main/java/org/jeecg/modules/cloud/xxl
job/DemoJobHandler.java
浏览文件 @
eb1578ad
package
org.jeecg.
cloud.demo.job
;
package
org.jeecg.
modules.cloud.xxljob
;
;
import
com.xxl.job.core.biz.model.ReturnT
;
...
...
@@ -230,5 +230,6 @@ public class DemoJobHandler {
public
void
destroy
()
{
log
.
info
(
"destory"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录