提交 e19332cd 编写于 作者: xiaonannet's avatar xiaonannet

更改打包方式,新增docker部署

上级 eeedad3b
......@@ -77,8 +77,6 @@ com.mqttsnet.thinglinks
规则引擎消息转发:支持KAFKA节点、HTTP节点、PREDICATE节点、ROCKET_MQ节点、RABBIT_MQ节点、MYSQL节点、MQTT节点、TOPIC节点、LOG节点
## 在线体验
- thinglinks/123456
......@@ -119,25 +117,25 @@ com.mqttsnet.thinglinks
~~~
1、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-gateway-1.0.0-RELEASE.jar >/dev/null 2>&1 &
1、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-gateway-1.0.0.RELEASE.jar >/dev/null 2>&1 &
2、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-auth-1.0.0-RELEASE.jar >/dev/null 2>&1 &
2、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-auth-1.0.0.RELEASE.jar >/dev/null 2>&1 &
3、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-file-1.0.0-RELEASE.jar >/dev/null 2>&1 &
3、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-file-1.0.0.RELEASE.jar >/dev/null 2>&1 &
4、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-gen-1.0.0-RELEASE.jar >/dev/null 2>&1 &
4、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-gen-1.0.0.RELEASE.jar >/dev/null 2>&1 &
5、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-job-1.0.0-RELEASE.jar >/dev/null 2>&1 &
5、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-job-1.0.0.RELEASE.jar >/dev/null 2>&1 &
6、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-system-1.0.0-RELEASE.jar >/dev/null 2>&1 &
6、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-system-1.0.0.RELEASE.jar >/dev/null 2>&1 &
7、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-tdengine-1.0.0-RELEASE.jar >/dev/null 2>&1 &
7、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-tdengine-1.0.0.RELEASE.jar >/dev/null 2>&1 &
8、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-link-1.0.0-RELEASE.jar >/dev/null 2>&1 &
8、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-link-1.0.0.RELEASE.jar >/dev/null 2>&1 &
9、nohup java -Xms400m -Xmx400m -Xmn150m -Xss512k -XX:MetaspaceSize=1024m -XX:MaxMetaspaceSize=1024m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-broker-1.0.0-RELEASE.jar >/dev/null 2>&1 &
9、nohup java -Xms400m -Xmx400m -Xmn150m -Xss512k -XX:MetaspaceSize=1024m -XX:MaxMetaspaceSize=1024m -server -jar -Dfile.encoding=utf-8 ./thinglinks-modules-broker-1.0.0.RELEASE.jar >/dev/null 2>&1 &
10、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-visual-monitor-1.0.0-RELEASE.jar >/dev/null 2>&1 &
10、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -jar -Dfile.encoding=utf-8 ./thinglinks-visual-monitor-1.0.0.RELEASE.jar >/dev/null 2>&1 &
11、nohup java -Xms150m -Xmx150m -Xmn100m -Xss512k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -server -Dserver.port=19101 -Dcsp.sentinel.dashboard.server=localhost:19101 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=thinglinks -Dsentinel.dashboard.auth.password=123456 -jar -Dfile.encoding=utf-8 ./sentinel-dashboard-1.8.2.jar >/dev/null 2>&1 &
......@@ -154,6 +152,11 @@ com.mqttsnet.thinglinks
- [Github](https://github.com/quickmsg/smqtt)
- [Gitee](https://gitee.com/quickmsg/mqtt-cluster)
MQTT客户端C库: thinglinks-mqtt-c
- [Github](https://github.com/mqttsnet/thinglinks-mqtt-c)
- [Gitee](https://gitee.com/mqttsnet/thinglinks-mqtt-c)
## License
[Apache License, Version 2.0](License)
......@@ -163,5 +166,3 @@ com.mqttsnet.thinglinks
## 交流社区
![image](doc/imgs/zsxq.jpg)
![image](doc/imgs/qq.jpg)
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/auth
ADD thinglinks-auth-1.0.0.RELEASE.jar auth.jar
EXPOSE 19200
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/auth.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/broker
ADD thinglinks-modules-broker-1.0.0.RELEASE.jar broker.jar
EXPOSE 19306
EXPOSE 11883
EXPOSE 18443
EXPOSE 18999
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/broker.jar"]
\ No newline at end of file
#!/bin/sh
# 使用说明,用来提示输入参数
usage() {
echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm]"
exit 1
}
# 开启所需端口
port(){
firewall-cmd --add-port=19000/tcp --permanent
firewall-cmd --add-port=19100/tcp --permanent
firewall-cmd --add-port=8848/tcp --permanent
firewall-cmd --add-port=9848/tcp --permanent
firewall-cmd --add-port=9849/tcp --permanent
firewall-cmd --add-port=6379/tcp --permanent
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=19300/tcp --permanent
firewall-cmd --add-port=11883/tcp --permanent
firewall-cmd --add-port=18443/tcp --permanent
firewall-cmd --add-port=18999/tcp --permanent
service firewalld restart
}
# 启动基础环境(必须)
base(){
docker-compose up -d thinglinks-mysql thinglinks-redis thinglinks-nacos
}
# 启动程序模块(必须)
modules(){
docker-compose up -d thinglinks-nginx thinglinks-gateway thinglinks-auth thinglinks-modules-file thinglinks-modules-gen thinglinks-modules-job thinglinks-modules-system thinglinks-modules-tdengine thinglinks-modules-link thinglinks-modules-broker thinglinks-visual-monitor thinglinks-visual-collection
}
# 关闭所有环境/模块
stop(){
docker-compose stop
}
# 删除所有环境/模块
rm(){
docker-compose rm
}
# 根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"port")
port
;;
"base")
base
;;
"modules")
modules
;;
"stop")
stop
;;
"rm")
rm
;;
*)
usage
;;
esac
#@mattsnet thinglinks Docker Compose管理容器
#参考文档
#https://www.jianshu.com/p/658911a8cff3
#https://www.runoob.com/docker/docker-compose.html
#dcoker 版本 yaml 配置实例
version: "3.8"
version: "3.9"
#thinglinks微服务集合
services:
#服务名称
gateway:
#什么情况重启 --非正常退出时候
#no:是默认的重启策略,在任何情况下都不会重启容器。
#always:容器总是重新启动。
#on-failure:在容器非正常退出时(退出状态非0),才会重启容器。
#unless-stopped:在容器退出时总是重启容器,但是不考虑在Docker守护进程启动时就已经停止了的容器
restart: on-failure
#创建镜像
build: ./gateway
#镜像名称
image: "gateway:1.0.0"
#容器名称
container_name: gateway
#加入网络
networks:
- thinglinks
#端口
thinglinks-nacos:
container_name: thinglinks-nacos
image: nacos/nacos-server
build:
context: ./nacos
environment:
- MODE=standalone
volumes:
- ./nacos/logs/:/www/wwwroot/thinglinks/nacos/logs
- ./nacos/conf/application.properties:/www/wwwroot/thinglinks/nacos/conf/application.properties
ports:
- "8848:8848"
- "9848:9848"
- "9849:9849"
depends_on:
- thinglinks-mysql
thinglinks-mysql:
container_name: thinglinks-mysql
image: mysql:5.7
build:
context: ./mysql
ports:
- "3306:3306"
volumes:
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/logs:/logs
- ./mysql/data:/var/lib/mysql
command: [
'mysqld',
'--innodb-buffer-pool-size=80M',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci',
'--default-time-zone=+8:00',
'--lower-case-table-names=1'
]
environment:
MYSQL_DATABASE: 'thinglinks'
MYSQL_ROOT_PASSWORD: password
thinglinks-redis:
container_name: thinglinks-redis
image: redis
build:
context: ./redis
ports:
- "6379:6379"
volumes:
- ./redis/conf/redis.conf:/www/wwwroot/thinglinks/redis/redis.conf
- ./redis/data:/data
command: redis-server /www/wwwroot/thinglinks/redis/redis.conf
thinglinks-nginx:
container_name: thinglinks-nginx
image: nginx
build:
context: ./nginx
ports:
- "80:80"
volumes:
- ./nginx/html/dist:/www/wwwroot/thinglinks/thinglinks-ui
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/log/nginx
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- thinglinks-gateway
links:
- thinglinks-gateway
thinglinks-gateway:
container_name: thinglinks-gateway
build:
context: ./thinglinks/gateway
dockerfile: dockerfile
ports:
- "19100:19100"
- "19101:19101"
oauth:
restart: on-failure
build: ./auth
image: "auth:1.0.0"
container_name: auth
networks:
- thinglinks
depends_on:
- thinglinks-redis
links:
- thinglinks-redis
thinglinks-auth:
container_name: thinglinks-auth
build:
context: ./thinglinks/auth
dockerfile: dockerfile
ports:
- "19200:19200"
file:
restart: on-failure
build: ./file
image: "file:1.0.0"
container_name: file
networks:
- thinglinks
depends_on:
- thinglinks-redis
links:
- thinglinks-redis
thinglinks-modules-file:
container_name: thinglinks-modules-file
build:
context: ./thinglinks/modules/file
dockerfile: dockerfile
ports:
- "19300:19300"
gen:
restart: on-failure
build: ./gen
image: "gen:1.0.0"
container_name: gen
networks:
- thinglinks
volumes:
- ./thinglinks/uploadPath:/www/wwwroot/thinglinks/uploadPath
thinglinks-modules-gen:
container_name: thinglinks-modules-gen
build:
context: ./thinglinks/modules/gen
dockerfile: dockerfile
ports:
- "19301:19301"
job:
restart: on-failure
build: ./job
image: "job:1.0.0"
container_name: job
networks:
- thinglinks
depends_on:
- thinglinks-mysql
links:
- thinglinks-mysql
thinglinks-modules-job:
container_name: thinglinks-modules-job
build:
context: ./thinglinks/modules/job
dockerfile: dockerfile
ports:
- "19302:19302"
system:
restart: on-failure
build: ./system
image: "system:1.0.0"
container_name: system
networks:
- thinglinks
depends_on:
- ruoyi-mysql
links:
- ruoyi-mysql
thinglinks-modules-system:
container_name: thinglinks-modules-system
build:
context: ./thinglinks/modules/system
dockerfile: dockerfile
ports:
- "19303:19303"
tdengine:
restart: on-failure
build: ./tdengine
image: "tdengine:1.0.0"
container_name: tdengine
networks:
- thinglinks
depends_on:
- thinglinks-redis
- thinglinks-mysql
links:
- thinglinks-redis
- thinglinks-mysql
thinglinks-modules-tdengine:
container_name: thinglinks-modules-tdengine
build:
context: ./thinglinks/modules/tdengine
dockerfile: dockerfile
ports:
- "19304:19304"
link:
restart: on-failure
build: ./link
image: "link:1.0.0"
container_name: link
networks:
- thinglinks
depends_on:
- thinglinks-redis
- thinglinks-mysql
links:
- thinglinks-redis
- thinglinks-mysql
thinglinks-modules-link:
container_name: thinglinks-modules-link
build:
context: ./thinglinks/modules/link
dockerfile: dockerfile
ports:
- "19305:19305"
broker:
restart: on-failure
build: ./broker
image: "broker:1.0.0"
container_name: broker
networks:
- thinglinks
depends_on:
- thinglinks-redis
- thinglinks-mysql
links:
- thinglinks-redis
- thinglinks-mysql
thinglinks-modules-broker:
container_name: thinglinks-modules-broker
build:
context: ./thinglinks/modules/broker
dockerfile: dockerfile
ports:
- "19306:19306"
- "11883:11883"
- "18443:18443"
- "18999:18999"
monitor:
restart: on-failure
build: ./monitor
image: "monitor:1.0.0"
container_name: monitor
networks:
- thinglinks
depends_on:
- thinglinks-redis
- thinglinks-mysql
links:
- thinglinks-redis
- thinglinks-mysql
thinglinks-visual-monitor:
container_name: thinglinks-visual-monitor
build:
context: ./thinglinks/visual/monitor
dockerfile: dockerfile
ports:
- "19400:19400"
networks:
thinglinks:
driver: bridge
\ No newline at end of file
thinglinks-visual-collection:
container_name: thinglinks-visual-collection
build:
context: ./thinglinks/visual/collection
dockerfile: dockerfile
ports:
- "19401:19401"
depends_on:
- thinglinks-redis
- thinglinks-mysql
links:
- thinglinks-redis
- thinglinks-mysql
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/file
ADD thinglinks-modules-file-1.0.0.RELEASE.jar file.jar
EXPOSE 19300
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/file.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/gateway
ADD thinglinks-gateway-1.0.0.RELEASE.jar gateway.jar
EXPOSE 19100
EXPOSE 19101
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/gateway.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/gen
ADD thinglinks-modules-gen-1.0.0.RELEASE.jar gen.jar
EXPOSE 19301
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/gen.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/job
ADD thinglinks-modules-job-1.0.0.RELEASE.jar job.jar
EXPOSE 19302
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/job.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/link
ADD thinglinks-modules-link-1.0.0.RELEASE.jar link.jar
EXPOSE 19305
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/link.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/monitor
ADD thinglinks-visual-monitor-1.0.0.RELEASE.jar monitor.jar
EXPOSE 19400
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/monitor.jar"]
\ No newline at end of file
存放sql目录下的所有脚本,用于docker自动执行。
\ No newline at end of file
# 基础镜像
FROM mysql:5.7
# author
MAINTAINER thinglinks
# 执行sql脚本
ADD ./db/*.sql /docker-entrypoint-initdb.d/
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://thinglinks-mysql:3306/thinglinks-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
db.password=password
nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000
management.endpoints.web.exposure.include=*
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.basedir=
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
nacos.core.auth.system.type=nacos
nacos.core.auth.enabled=false
nacos.core.auth.default.token.expire.seconds=18000
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.core.auth.caching.enabled=true
nacos.core.auth.enable.userAgentAuthWhite=false
nacos.core.auth.server.identity.key=serverIdentity
nacos.core.auth.server.identity.value=security
nacos.istio.mcp.server.enabled=false
# 基础镜像
FROM nacos/nacos-server
# author
MAINTAINER thinglinks
# 复制conf文件到路径
COPY ./conf/application.properties /www/wwwroot/thinglinks/nacos/conf/application.properties
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#thinglinks网关服务
upstream gateway_upstream {
server 127.0.0.1:19100;
}
#thinglinks-web
server {
listen 19000;
server_name 127.0.0.1;
charset utf-8;
access_log /www/wwwlogs/thinglinks.log;
# 注意设定 root路径为dist文件解压后的所在的目录
location / {
root /www/wwwroot/thinglinks/thinglinks-ui;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://gateway_upstream/;
}
location /prod-soket/ {
proxy_pass http://gateway_upstream/;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
}
}
}
\ No newline at end of file
# 基础镜像
FROM nginx
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-ui
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-ui
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-ui
# 复制conf文件到路径
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
# 复制html文件到路径
COPY ./html/dist /www/wwwroot/thinglinks/thinglinks-ui
存放前端thinglinks-ui构建好的静态文件,用于nginx请求访问。
\ No newline at end of file
# requirepass 123456
\ No newline at end of file
# 基础镜像
FROM redis
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/redis
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/redis
# 指定路径
WORKDIR /www/wwwroot/thinglinks/redis
# 复制conf文件到路径
COPY ./conf/redis.conf /www/wwwroot/thinglinks/redis/redis.conf
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/system
ADD thinglinks-modules-system-1.0.0.RELEASE.jar system.jar
EXPOSE 19303
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/system.jar"]
\ No newline at end of file
# mqttsnet=docker/dockerfile:1
FROM java:8
#FROM primetoninc/jdk:1.8
VOLUME /tmp/tdengine
ADD thinglinks-modules-tdengine-1.0.0.RELEASE.jar tdengine.jar
EXPOSE 19304
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/tdengine.jar"]
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-auth-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/auth/auth.jar
# 启动认证服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/auth.jar"]
\ No newline at end of file
存放认证中心打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-modules-broker-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/broker/broker.jar
# 启动broker服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/broker.jar"]
\ No newline at end of file
存放Broker服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-visual-collection-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/collection/collection.jar
# 启动服务器监控采集服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/collection.jar"]
\ No newline at end of file
存放服务器监控采集服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-modules-file-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/file/file.jar
# 启动文件服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/file.jar"]
\ No newline at end of file
存放文件服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-gateway-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/gateway/gateway.jar
# 启动网关模块
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/gateway.jar"]
\ No newline at end of file
存放网关模块打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-modules-gen-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/gen/gen.jar
# 启动代码生成服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/gen.jar"]
\ No newline at end of file
存放代码生成服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-modules-job-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/job/job.jar
# 启动定时任务服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/job.jar"]
\ No newline at end of file
存放定时任务服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-modules-link-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/link/link.jar
# 启动Link服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/link.jar"]
\ No newline at end of file
存放Link服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-visual-monitor-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/monitor/monitor.jar
# 启动监控中心
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/monitor.jar"]
\ No newline at end of file
存放监控中心打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-system-modules-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/system/system.jar
# 启动系统模块
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/system.jar"]
\ No newline at end of file
存放系统模块打包好的jar文件,用于docker启动应用。
\ No newline at end of file
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER thinglinks
# 挂载目录
VOLUME /www/wwwroot/thinglinks/thinglinks-server
# 创建目录
RUN mkdir -p /www/wwwroot/thinglinks/thinglinks-server
# 指定路径
WORKDIR /www/wwwroot/thinglinks/thinglinks-server
# 复制jar文件到路径
COPY ./jar/thinglinks-modules-modules-tdengine-1.0.0.RELEASE.jar /www/wwwroot/thinglinks/thinglinks-server/tdengine/tdengine.jar
# 启动TDengine服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "/tdengine.jar"]
\ No newline at end of file
存放TDengine服务打包好的jar文件,用于docker启动应用。
\ No newline at end of file
......@@ -40,26 +40,6 @@ spring:
# url:
# driver-class-name:
# seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭
#kafka
kafka:
bootstrap-servers: 127.0.0.1:9092
producer:
retries: 0
batch-size: 16384
buffer-memory: 33554432
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
properties:
linger.ms: 1
consumer:
enable-auto-commit: false
auto-commit-interval: 100ms
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
properties:
session.timeout.ms: 15000
group-id: thinglinks
# rocketmq地址
rocketmq:
......
......@@ -13,7 +13,7 @@
<description>ThingLinks物联网一体化平台</description>
<properties>
<thinglinks.version>1.0.0-RELEASE</thinglinks.version>
<thinglinks.version>1.0.0.RELEASE</thinglinks.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
......@@ -39,7 +39,8 @@
<common-pool.version>2.11.1</common-pool.version>
<commons-collections.version>3.2.2</commons-collections.version>
<!--lib打包目录-->
<thinglinks.lib.package.url>D:\thinglinks-server\lib\</thinglinks.lib.package.url>
<!--suppress UnresolvedMavenProperty -->
<thinglinks.lib.package.url>${project.basedir}\doc\dockerfile\thinglinks\lib\</thinglinks.lib.package.url>
<!-- 文件拷贝时的编码 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
......
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
......@@ -16,7 +16,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\auth</thinglinks.package.url>
<thinglinks.package.url>${project.parent.basedir}\doc\dockerfile\thinglinks\auth\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.auth.ThingLinksAuthApplication</thinglinks.mainClass.url>
</properties>
......
package com.mqttsnet.thinglinks.common.core.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD) // 作用到方法上
@Retention(RetentionPolicy.RUNTIME) // 运行时有效
/**
* @功能描述 防止重复提交标记注解
* @author thinglinks
* @date 2022-02-15
*/
public @interface NoRepeatSubmit {
}
......@@ -15,7 +15,7 @@ public class UserConstants
/**
* 平台默认管理员
*/
public static final String MQTTS = "mqtts";
public static final String THINGLINKS = "thinglinks";
/**
* 平台内系统用户的唯一标志
......
......@@ -19,7 +19,7 @@ public class SecurityUtils {
public static String getUsername() {
String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME);
if (StringUtils.isEmpty(username)) {
return UserConstants.MQTTS;
return UserConstants.THINGLINKS;
}
return ServletUtils.urlDecode(username);
}
......
......@@ -16,7 +16,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\gateway</thinglinks.package.url>
<thinglinks.package.url>${project.parent.basedir}\doc\dockerfile\thinglinks\gateway\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.gateway.ThingLinksGatewayApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\broker</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\broker\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.broker.ThingLinksBrokerApplication</thinglinks.mainClass.url>
</properties>
......
package com.mqttsnet.thinglinks.broker.Actors;
import io.github.quickmsg.common.annotation.AllowCors;
import io.github.quickmsg.common.annotation.Header;
import io.github.quickmsg.common.annotation.Router;
import io.github.quickmsg.common.config.Configuration;
import io.github.quickmsg.common.enums.HttpType;
......@@ -27,20 +28,18 @@ import java.nio.charset.StandardCharsets;
*/
@Router(value = "/publish", type = HttpType.POST)
@Slf4j
@Header(key = "Content-Type", value = "application/json")
@AllowCors
public class PublishActor extends AbstractHttpActor {
@Override
public Publisher<Void> doRequest(HttpServerRequest request, HttpServerResponse response, Configuration httpConfiguration) {
Charset charset = Charset.defaultCharset();
log.info("Charset is {}",charset);
public Publisher<Void> doRequest(HttpServerRequest request, HttpServerResponse response, Configuration configuration) {
return request
.receive()
.asString(StandardCharsets.UTF_8)
.asString()
.map(this.toJson(HttpPublishMessage.class))
.doOnNext(message -> {
this.sendMqttMessage(message.getPublishMessage());
log.info("http request url {} body {}", request.path(), message);
//处理request
}).then(response.sendString(Mono.just("success")).then());
}
}
package com.mqttsnet.thinglinks.broker.service;
import io.github.quickmsg.common.message.MessageRegistry;
import io.github.quickmsg.common.message.RetainMessage;
import io.github.quickmsg.common.message.SessionMessage;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description: 主要提供 session消息 && 保留消息的持久化
* @Author: ShiHuan Sun
* @E-mail: 13733918655@163.com
* @CreateDate: 2021/10/25$ 17:35$
* @UpdateUser: ShiHuan Sun
* @UpdateDate: 2021/10/25$ 17:35$
* @UpdateRemark: 修改内容
* @Version: 1.0
*/
@Service
public class MessageRegistryImpl implements MessageRegistry {
/**
* 获取连接下线后的session消息
*
* @param clientIdentifier 设备id
* @return {@link SessionMessage}
*/
@Override
public List<SessionMessage> getSessionMessage(String clientIdentifier) {
return null;
}
/**
* 发送连接下线后的session消息
*
* @param sessionMessage {@link SessionMessage}
*/
@Override
public void saveSessionMessage(SessionMessage sessionMessage) {
}
/**
* 保留Topic保留消息
*
* @param retainMessage {@link RetainMessage}
*/
@Override
public void saveRetainMessage(RetainMessage retainMessage) {
}
/**
* 保留Topic保留消息
*
* @param topic topic
* @return {@link RetainMessage}
*/
@Override
public List<RetainMessage> getRetainMessage(String topic) {
return null;
}
}
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\file</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\file\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.file.ThingLinksFileApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\gen</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\gen\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.gen.ThingLinksGenApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\job</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\job\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.job.ThingLinksJobApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\link</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\link\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.link.ThingLinksLinkApplication</thinglinks.mainClass.url>
</properties>
......
package com.mqttsnet.thinglinks.link.common.aop;
import com.mqttsnet.thinglinks.common.core.annotation.NoRepeatSubmit;
import com.mqttsnet.thinglinks.common.core.utils.SecurityUtils;
import com.mqttsnet.thinglinks.common.core.web.domain.AjaxResult;
import com.mqttsnet.thinglinks.common.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;
/**
* @author thinglinks
* @功能描述 防止多次提交aop解析注解
* @date 2022-02-15
*/
@Slf4j
@Aspect
@Component
public class NoRepeatSubmitAop {
@Autowired
private RedisService redisService;
@Around("execution(* com.mqttsnet.thinglinks.link.controller..*.*(..)) && @annotation(nrs)")
public Object arround(ProceedingJoinPoint pjp, NoRepeatSubmit nrs) {
try {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
log.info("请求地址:{}", request.getServletPath());
String key = SecurityUtils.getToken() + "-" + request.getServletPath();
log.info("newToken:{}", key);
if (!redisService.hasKey(key)) {// 如果缓存中有这个url视为重复提交
Object o = pjp.proceed();//当使用环绕通知时,这个方法必须调用,否则拦截到的方法就不会再执行了
redisService.setCacheObject(key, o, 2L, TimeUnit.SECONDS);
return o;
} else {
log.error("请勿重复提交");
return AjaxResult.error("请勿重复提交");
}
} catch (Throwable e) {
e.printStackTrace();
log.error("验证重复提交时出现未知异常!");
return AjaxResult.error("内部服务异常!");
}
}
}
\ No newline at end of file
package com.mqttsnet.thinglinks.link.common.kafka.consumer;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import java.util.Optional;
/**
* @Description: kafka消费者
* @Author: ShiHuan Sun
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2021/11/27$ 16:02$
* @UpdateUser: ShiHuan Sun
* @UpdateDate: 2021/11/27$ 16:02$
* @UpdateRemark: 修改内容
* @Version: 1.0
*/
@RefreshScope
@Component
@EnableKafka
@Slf4j
public class KafkaConsumer {
//消费者:监听topic1
@KafkaListener(topics = {"thinglinks-link"})
public void consumer1(ConsumerRecord<Integer,String> record){
Optional message = Optional.ofNullable(record.value());
if (message.isPresent()) {
Object msg = message.get();
log.info("kafka消费: Topic:" + record.topic() + ",Message:" + msg);
}
}
//消费者:监听mqtts,groupId2
@KafkaListener(topics = {"thinglinks-link"},groupId = "groupId2")
public void consumer3(ConsumerRecord<Integer,String> record){
Optional message = Optional.ofNullable(record.value());
if (message.isPresent()) {
Object msg = message.get();
log.info("kafka消费: Topic:" + record.topic() + ",Message:" + msg);
}
}
//消费者:监听mqtts,groupId2
@KafkaListener(topics = {"thinglinks-link"},groupId = "groupId2")
public void consumer2(ConsumerRecord<Integer,String> record){
Optional message = Optional.ofNullable(record.value());
if (message.isPresent()) {
Object msg = message.get();
log.info("kafka消费: Topic:" + record.topic() + ",Message:" + msg);
}
}
}
//package com.mqttsnet.thinglinks.link.common.kafka.consumer;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
//import org.springframework.kafka.annotation.EnableKafka;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.stereotype.Component;
//
//import java.util.Optional;
//
///**
// * @Description: kafka消费者
// * @Author: ShiHuan Sun
// * @E-mail: 13733918655@163.com
// * @Website: http://thinglinks.mqttsnet.com
// * @CreateDate: 2021/11/27$ 16:02$
// * @UpdateUser: ShiHuan Sun
// * @UpdateDate: 2021/11/27$ 16:02$
// * @UpdateRemark: 修改内容
// * @Version: 1.0
// */
//@RefreshScope
//@Component
//@EnableKafka
//@Slf4j
//public class KafkaConsumer {
//
// //消费者:监听topic1
// @KafkaListener(topics = {"thinglinks-link"})
// public void consumer1(ConsumerRecord<Integer,String> record){
// Optional message = Optional.ofNullable(record.value());
// if (message.isPresent()) {
// Object msg = message.get();
// log.info("kafka消费: Topic:" + record.topic() + ",Message:" + msg);
// }
// }
// //消费者:监听mqtts,groupId2
// @KafkaListener(topics = {"thinglinks-link"},groupId = "groupId2")
// public void consumer3(ConsumerRecord<Integer,String> record){
// Optional message = Optional.ofNullable(record.value());
// if (message.isPresent()) {
// Object msg = message.get();
// log.info("kafka消费: Topic:" + record.topic() + ",Message:" + msg);
// }
// }
// //消费者:监听mqtts,groupId2
// @KafkaListener(topics = {"thinglinks-link"},groupId = "groupId2")
// public void consumer2(ConsumerRecord<Integer,String> record){
// Optional message = Optional.ofNullable(record.value());
// if (message.isPresent()) {
// Object msg = message.get();
// log.info("kafka消费: Topic:" + record.topic() + ",Message:" + msg);
// }
// }
//}
package com.mqttsnet.thinglinks.link.common.kafka.producer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
/**
* @Description: kafka生产者
* @Author: ShiHuan Sun
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2021/11/27$ 16:04$
* @UpdateUser: ShiHuan Sun
* @UpdateDate: 2021/11/27$ 16:04$
* @UpdateRemark: 修改内容
* @Version: 1.0
*/
@RefreshScope
@Component
@EnableKafka
@Slf4j
public class KafkaProducer {
@Autowired
private KafkaTemplate<Integer,String> kafkaTemplate;
//生产者
public void sendMsg(String topic , String msg){
log.info("开始发送kfk消息,topic:{},msg:{}",topic,msg);
ListenableFuture<SendResult<Integer, String>> sendMsg = kafkaTemplate.send(topic, msg);
//消息确认
sendMsg.addCallback(new ListenableFutureCallback<SendResult<Integer, String>>() {
@Override
public void onFailure(Throwable throwable) {
log.error("send error,ex:{},topic:{},msg:{}",throwable,topic,msg);
}
@Override
public void onSuccess(SendResult<Integer, String> stringStringSendResult) {
log.info("send success,topic:{},msg:{}",topic,msg);
}
});
log.info("kfk send end!");
}
}
//package com.mqttsnet.thinglinks.link.common.kafka.producer;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
//import org.springframework.kafka.annotation.EnableKafka;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.kafka.support.SendResult;
//import org.springframework.stereotype.Component;
//import org.springframework.util.concurrent.ListenableFuture;
//import org.springframework.util.concurrent.ListenableFutureCallback;
//
///**
// * @Description: kafka生产者
// * @Author: ShiHuan Sun
// * @E-mail: 13733918655@163.com
// * @Website: http://thinglinks.mqttsnet.com
// * @CreateDate: 2021/11/27$ 16:04$
// * @UpdateUser: ShiHuan Sun
// * @UpdateDate: 2021/11/27$ 16:04$
// * @UpdateRemark: 修改内容
// * @Version: 1.0
// */
//@RefreshScope
//@Component
//@EnableKafka
//@Slf4j
//public class KafkaProducer {
// @Autowired
// private KafkaTemplate<Integer,String> kafkaTemplate;
//
// //生产者
// public void sendMsg(String topic , String msg){
// log.info("开始发送kfk消息,topic:{},msg:{}",topic,msg);
//
// ListenableFuture<SendResult<Integer, String>> sendMsg = kafkaTemplate.send(topic, msg);
// //消息确认
// sendMsg.addCallback(new ListenableFutureCallback<SendResult<Integer, String>>() {
// @Override
// public void onFailure(Throwable throwable) {
// log.error("send error,ex:{},topic:{},msg:{}",throwable,topic,msg);
// }
//
// @Override
// public void onSuccess(SendResult<Integer, String> stringStringSendResult) {
// log.info("send success,topic:{},msg:{}",topic,msg);
// }
// });
// log.info("kfk send end!");
// }
//}
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mqttsnet.thinglinks.common.core.annotation.NoRepeatSubmit;
import com.mqttsnet.thinglinks.common.core.domain.R;
import com.mqttsnet.thinglinks.common.core.utils.poi.ExcelUtil;
import com.mqttsnet.thinglinks.common.core.web.controller.BaseController;
......@@ -67,6 +68,7 @@ public class DeviceController extends BaseController {
/**
* 新增设备管理
*/
@NoRepeatSubmit
@PreAuthorize(hasPermi = "link:device:add")
@Log(title = "设备管理", businessType = BusinessType.INSERT)
@PostMapping
......@@ -78,6 +80,7 @@ public class DeviceController extends BaseController {
/**
* 修改设备管理
*/
@NoRepeatSubmit
@PreAuthorize(hasPermi = "link:device:edit")
@Log(title = "设备管理", businessType = BusinessType.UPDATE)
@PutMapping
......@@ -100,7 +103,6 @@ public class DeviceController extends BaseController {
/**
* 更新设备在线状态
*/
@Log(title = "设备管理", businessType = BusinessType.UPDATE)
@PutMapping("/updateConnectStatusByClientId")
public R updateConnectStatusByClientId(@RequestBody Device device) {
return R.ok(deviceService.updateConnectStatusByClientId(device.getConnectStatus(), device.getClientId()));
......
package com.mqttsnet.thinglinks.link.controller.kafka;
import com.mqttsnet.thinglinks.link.common.kafka.producer.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @Description: kafka接口
* @Author: ShiHuan Sun
* @E-mail: 13733918655@163.com
* @Website: http://thinglinks.mqttsnet.com
* @CreateDate: 2021/12/1$ 11:39$
* @UpdateUser: ShiHuan Sun
* @UpdateDate: 2021/12/1$ 11:39$
* @UpdateRemark: 修改内容
* @Version: 1.0
*/
@RestController
@RequestMapping("/kafkaMessage")
public class KafkaController {
@Autowired
private KafkaProducer kafkaProducer;
@PostMapping("/send")
public String kafkaMessageSend(@RequestBody Map<String, String> params){
kafkaProducer.sendMsg(String.valueOf(params.get("topic")),String.valueOf(params.get("msg")));
return "success-"+params.get("topic");
}
}
//package com.mqttsnet.thinglinks.link.controller.kafka;
//
//import com.mqttsnet.thinglinks.link.common.kafka.producer.KafkaProducer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.Map;
//
///**
// * @Description: kafka接口
// * @Author: ShiHuan Sun
// * @E-mail: 13733918655@163.com
// * @Website: http://thinglinks.mqttsnet.com
// * @CreateDate: 2021/12/1$ 11:39$
// * @UpdateUser: ShiHuan Sun
// * @UpdateDate: 2021/12/1$ 11:39$
// * @UpdateRemark: 修改内容
// * @Version: 1.0
// */
//@RestController
//@RequestMapping("/kafkaMessage")
//public class KafkaController {
// @Autowired
// private KafkaProducer kafkaProducer;
//
// @PostMapping("/send")
// public String kafkaMessageSend(@RequestBody Map<String, String> params){
// kafkaProducer.sendMsg(String.valueOf(params.get("topic")),String.valueOf(params.get("msg")));
// return "success-"+params.get("topic");
// }
//}
......@@ -2,6 +2,7 @@ package com.mqttsnet.thinglinks.link.controller.product;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.mqttsnet.thinglinks.common.core.annotation.NoRepeatSubmit;
import com.mqttsnet.thinglinks.common.core.constant.Constants;
import com.mqttsnet.thinglinks.common.core.constant.HttpStatus;
import com.mqttsnet.thinglinks.common.core.utils.poi.ExcelUtil;
......@@ -126,6 +127,7 @@ public class ProductController extends BaseController {
/**
* 新增产品管理
*/
@NoRepeatSubmit
@PreAuthorize(hasPermi = "link:product:add")
@Log(title = "产品管理", businessType = BusinessType.INSERT)
@PostMapping
......@@ -137,6 +139,7 @@ public class ProductController extends BaseController {
/**
* 修改产品管理
*/
@NoRepeatSubmit
@PreAuthorize(hasPermi = "link:product:edit")
@Log(title = "产品管理", businessType = BusinessType.UPDATE)
@PutMapping
......
......@@ -37,7 +37,7 @@
delete from device_action
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="i d" parameterType="com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceAction" useGeneratedKeys="true">
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.mqttsnet.thinglinks.link.api.domain.device.entity.DeviceAction" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into device_action (device_identification, action_type,
`status`, create_time, `message`
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\system</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\system\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.system.ThingLinksSystemApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\tdengine</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\tdengine\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.tdengine.ThingLinksTdengineApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -17,7 +17,7 @@
<properties>
<!--打包目录-->
<thinglinks.package.url>D:\thinglinks-server\collection</thinglinks.package.url>
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\collection\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.collection.ThingLinksCollectionApplication</thinglinks.mainClass.url>
</properties>
......
......@@ -3,13 +3,25 @@
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>thinglinks-visual</artifactId>
<groupId>com.mqttsnet</groupId>
<artifactId>thinglinks-visual</artifactId>
<version>${thinglinks.version}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>thinglinks-visual-monitor</artifactId>
<description>
thinglinks-visual-monitor 监控中心
</description>
<properties>
<!--打包目录-->
<thinglinks.package.url>${project.parent.parent.basedir}\doc\dockerfile\thinglinks\monitor\jar</thinglinks.package.url>
<!--启动类目录-->
<thinglinks.mainClass.url>com.mqttsnet.thinglinks.collection.ThingLinksCollectionApplication</thinglinks.mainClass.url>
</properties>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册