Git Product home page Git Product logo

cnrainbing / exchange Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lmxdawn/exchange

1.0 0.0 0.0 1.05 MB

Java 交易所源码,前端APP使用uniapp开发,后端使用java开发,采用 Spring Cloud Alibaba 微服务架构,撮合引擎使用`Disruptor`高效内存队列,所有服务可以实现分布式部署,websocket推送通过增加一层路由服务实现分布式部署

Shell 0.35% Python 0.16% Java 98.87% HTML 0.63%

exchange's Introduction

工程简介

Java 交易所源码,前端APP使用uniapp开发,后端使用java开发,采用 Spring Cloud Alibaba 微服务架构,撮合引擎使用Disruptor高效内存队列,所有服务可以实现分布式部署,websocket推送通过增加一层路由服务实现分布式部署

如果对你有帮助,麻烦小手给一个star

前端说明

之前由于uniapp的闪屏一度准备放弃,暂时解决闪屏问题,重新开始开发

uni-app切换页面闪屏或者白屏

前端代码,点击跳转

依赖环境

先运行 Nacos 服务。点击跳转官方文档

  • Linux/Unix/Mac
$ sh startup.sh -m standalone
  • 如果您使用的是ubuntu系统,或者运行脚本报错提示[[符号找不到,可尝试如下运行:
bash startup.sh -m standalone
  • Windows
$ startup.cmd -m standalone

再运行 Seata 服务。点击跳转官方文档

  • script/seata 目录下面查看配置seata的教程,需要运行SQL和把配置文件传到nacos

  • 在 Linux/Mac 下

$ ./bin/seata-server.sh -h 127.0.0.1 -p 8091 -m db
  • 在 Windows 下
$ bin\seata-server.bat -h 127.0.0.1 -p 8091 -m db

再运行 rocketmq 消息队列服务。点击跳转官方文档

  • rocketmq分name服务和broker服务

  • Linux

# Start Name Server 启动名称服务器
$ nohup sh bin/mqnamesrv &
# Start Broker 启动代理
$ nohup sh bin/mqbroker -n localhost:9876 &
  • Windows

  • 先设置环境变量:ROCKETMQ_HOME="D:\rocketmq"

# Start Name Server 启动名称服务器
$ .\bin\mqnamesrv.cmd
# Start Broker 启动代理
$ .\bin\mqbroker.cmd -n localhost:9876

如果windows启动代理报错:错误: 找不到或无法加载主类 Files\Java\jdk1.8.0_301\lib\dt.jar;C:\Program,这个报错原因是因为java环境安装路径包含了空格

解决方案:点击查看 runbroker.cmd 内容在文章底部有

下载-打包

git clone https://github.com/lmxdawn/exchange.git

# 整体打包
mvn -Dmaven.test.skip=true clean package
# 单独打包某个模块,这里的 user 就是模块名称
mvn -Dmaven.test.skip=true -pl user -am clean package

# 运行
nohup java -jar -Dspring.profiles.active=prod admin/target/admin-0.0.1-SNAPSHOT.jar &
nohup java -jar -Dspring.profiles.active=prod gateway/target/gateway-0.0.1-SNAPSHOT.jar &
nohup java -jar -Dspring.profiles.active=prod user/target/user-0.0.1-SNAPSHOT.jar &

模块说明

dubbo-api:dubbo的API

gateway:网关 9001

admin:后台 9002

other:其它模块 9003

user:用户 9004

wallet:钱包 9005

market:行情 9006

trade:交易 9007

match:撮合 9008

ws:消息推送 9009

ws-route:消息推送路由 9010

robot:机器人 9011

Swagger

gateway的方式访问swagger,gateway启动后访问: http://ip:prot/swagger-ui/index.html

使用

dubbo 做微服务的调用

Seata 做微服务的分布式事务,操作目录 script/seata 安装步骤

使用 jwt 做dubbo服务间的鉴权

example 目录是示例文件,需要加 module 时创建一个module,然后复制example里面的代码,全局替换 example

依赖

Java 8

Maven 3.6.1 版本控制

RocketMQ 4.9.3 消息队列

Nacos 2.0.3 操作文档:https://nacos.io/zh-cn/docs/quick-start.html

Redis 3 缓存服务

MySQL 5.7 数据库服务

MongoDB 5.0.5 K线数据库服务

Seata 1.3.0 分布式事务解决方案

Disruptor 3.4.4 高效的内存队列,为了多线程操作变量时并发问题,用这个可以不用锁

Netty 4.1.71.Final ws消息推送

其它

Generate MyPOJOs.groovy 生成数据库Model

RocketMQ 的 runbroker.cmd

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

set JAVAHOME="%JAVA_HOME%"
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
set "JAVA=%JAVA_HOME%\bin\java.exe"

setlocal

set BASE_DIR=%~dp0
set BASE_DIR=%BASE_DIR:~0,-1%
for %%d in (%BASE_DIR%) do set BASE_DIR=%%~dpd

set CLASSPATHSTR="%CLASSPATH%"
set CLASSPATH=.;%BASE_DIR%conf;%BASE_DIR%lib\*;%CLASSPATHSTR%

rem ===========================================================================================
rem  JVM Configuration
rem ===========================================================================================
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g"
set "JAVA_OPT=%JAVA_OPT% -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:%USERPROFILE%\mq_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
set "JAVA_OPT=%JAVA_OPT% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
set "JAVA_OPT=%JAVA_OPT% -XX:+AlwaysPreTouch"
set "JAVA_OPT=%JAVA_OPT% -XX:MaxDirectMemorySize=15g"
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages -XX:-UseBiasedLocking"
set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib;%JAVAHOME%\jre\lib\ext"
set "JAVA_OPT=%JAVA_OPT% -cp %CLASSPATH%"

"%JAVA%" %JAVA_OPT% %*

exchange's People

Contributors

lmxdawn avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.