All Projects → frjufvjn → vertx-mybatis

frjufvjn / vertx-mybatis

Licence: MIT license
vertx sqlclient template using mybatis NON-BLOCK & ASYNCHRONOUS

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to vertx-mybatis

IntroduceToEclicpseVert.x
This repository contains the code of Vert.x examples contained in my articles published on platforms such as kodcu.com, medium, dzone. How to run each example is described in its readme file.
Stars: ✭ 27 (+17.39%)
Mutual labels:  reactive-programming, vertx
Vertx Blueprint Todo Backend
Vert.x Blueprint Project - A reactive todo-backend implementation using Vert.x and various persistence
Stars: ✭ 169 (+634.78%)
Mutual labels:  reactive-programming, vertx
Vertx Embedded Springboot
Vert.x embeded Springboot
Stars: ✭ 19 (-17.39%)
Mutual labels:  vertx, mybatis
ncms
Java CMS engine. Host and develop multiple websites inside a single instance through the GUI and benefit from features like A/B testing, affiliate tracking tools, and a high performance template engine with CSS stylesheets processing & scripts minification.
Stars: ✭ 32 (+39.13%)
Mutual labels:  mybatis, guice
slush-vertx
No description or website provided.
Stars: ✭ 36 (+56.52%)
Mutual labels:  vertx
mech
🦾 Main repository for the Mech programming language. Start here!
Stars: ✭ 135 (+486.96%)
Mutual labels:  reactive-programming
Binder
🦁"Hello World" <-> [🏷, 🏷, 🏷, 🏷]
Stars: ✭ 37 (+60.87%)
Mutual labels:  reactive-programming
mayday
mayday博客系统,基于springboot、mybatis、ehcache、thymeleaf、bootstrap做的博客系统,完美自适应,支持markdown编辑器
Stars: ✭ 113 (+391.3%)
Mutual labels:  mybatis
seckill parent
基于springboot+springcloud的高并发和商品秒杀项目,通过redis,rabbitmq等技术实现秒杀的高并发。
Stars: ✭ 59 (+156.52%)
Mutual labels:  mybatis
vertx-jooq-async
Deprecated, use vertx-jooq instead:
Stars: ✭ 27 (+17.39%)
Mutual labels:  vertx
RPC reactive
Examples and explanations of how RPC systems works.
Stars: ✭ 25 (+8.7%)
Mutual labels:  reactive-programming
SqlBatis
A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite etc..
Stars: ✭ 34 (+47.83%)
Mutual labels:  mybatis
SpringBootMovie
基于Spring Boot的电影网站
Stars: ✭ 56 (+143.48%)
Mutual labels:  mybatis
springboot-chapter
🚀Spring Boot 2.0基础教程。主流框架整合,实践学习案例。
Stars: ✭ 23 (+0%)
Mutual labels:  mybatis
basemall
🥇🥇🥇商城系统- java商城 B2C商城 小程序商城 H5商城 APP商城 ,本商城是前后端分离的商城、微服务架构商城。
Stars: ✭ 339 (+1373.91%)
Mutual labels:  mybatis
fpEs
Functional Programming for EcmaScript(Javascript)
Stars: ✭ 40 (+73.91%)
Mutual labels:  reactive-programming
mybatis-examples
mybatis 使用示例
Stars: ✭ 78 (+239.13%)
Mutual labels:  mybatis
vertx-graphql-utils
Vert.x GraphQL utils
Stars: ✭ 22 (-4.35%)
Mutual labels:  vertx
read
学习笔记 dubbo,rocketmq 源码解析
Stars: ✭ 33 (+43.48%)
Mutual labels:  mybatis
vxrifa
Utility library for Vert.X that allows using strong-typed interfaces in communication through EventBus
Stars: ✭ 15 (-34.78%)
Mutual labels:  vertx

vertx-mybatis Success

Use asynchronous non-blocking database access using the sql client provided by vertx. Then you organize your project so that it is easy to use without giving up the SQL Mapper framework (MyBatis) ORM framework.

Description

Synopsis

pure vertx sql client

The code block below is an example of a pure sql client code provided by vertx. I wanted to build an sql service using (without giving up) an SQL Mapper framework like mybatis.

final SQLConnection connection = conn.result();
connection.queryWithParams("select * from test where id = ?", new JsonArray().add(2), rs -> {
    ...
});

get query and param

Once you have mybatis sqlsession, you can use BoundSql and ParameterMapping methods to retrieve queries and parameters and use them in your vertex sql client. See QueryGetter.java

  • org.apache.ibatis.mapping.BoundSql
  • org.apache.ibatis.mapping.ParameterMapping
// Get BoudSql
BoundSql boundSql = sqlsession.getConfiguration()
        .getMappedStatement(sqlName) // MyBatis SQL ID
        .getSqlSource()
        .getBoundSql(reqData)
        ;
// A query containing '?' Is returned.
queryString = boundSql.getSql();

// The parameters defined in the mapper are returned.
List<ParameterMapping> paramMapping = boundSql.getParameterMappings();
for ( ParameterMapping mapping : paramMapping ) {
    String key = mapping.getProperty();
    Object value = ((Map<String,Object>)reqData).get(key);
}

Usecase

Goal

Provides boilerplate for developers to create sql only and make it easy to access api server easily.

The way to make REST API

  1. Create or Edit MyBatis mapper.xml
  2. URL
  • C: /api/create, R: /api/read, U: /api/update, D: /api/delete
  • Batch C: /api/create/multi, U: /api/update/multi, D: /api/delete/multi
  1. HTTP POST method Call
header --> "Authorization": "Bearer `JWT Token`" // It can be obtained through "/api/newToken" service.
payload = {
    sqlName: 'sqlid', // mybatis sql id
    param1: 'foo',
    param2: 'bar',
    ...
}

CRUD API feature

related codes

Batch CUD API feature

related codes

Realtime changed data Pub/Sub feature

- MySQL

Use mysql-binlog-connector-java & Inspired by vertx-mysql-binlog-client

Thanks!!

Unlike the vertx-mysql-binlog-client, however, it does not release row-level events, but instead emit events in TR range.

related codes

- PostgreSQL (WIP)

GraphQL Integration (WIP)

Large DB data csv export

Recently, we had to add a large Excel download to an existing web application that had a lot of side effects when adding services.

  1. Invoke the REST API with parameters including the number of patches to the legacy application (Spring framework), assuming 50,000 data requests.
  2. Establish appropriate paging rules (eg, 10,000 responses) to invoke the DB service by dividing 50,000 requests into 10,000 requests.
  3. Call the DB service n times as defined in step 2.
  4. Use vertex sql client to process asynchronous non-block.
  5. Process vertex cvs parsing using queryStream () of vertx and generate csv file asynchronously using vertex fileSystem () feature. You can see that the processed result is different to the order requested, as shown by the arrow in the figure. (AsyncResult)
  6. CompositeFuture.all () is used to wait for the future of all the processing results, and then batches the response processing.
  7. Get the csv file path list in the Legacy Application.
  8. Stream the HTTP chunked response with the file list in step 7.

title

Codes View

title

Codes Tree

public void main () {
.
├── bin
│   ├── build.sh // Maven build script
│   ├── config-to-server.sh // Apply server properties
│   ├── memchk.sh // Linux Server Target Process Memory View
│   └── run.sh // This application start and stop script
├── pom.xml
├── run.bat
└── src
    └── main
        ├── java
        │   └── io
        │       └── frjufvjn
        │           └── lab
        │               └── vertx_mybatis
        │                   ├── AppMain.java // Direct Execute Application in IDE Without CLI
        │                   ├── BareInstance.java
        │                   ├── Constants.java
        │                   ├── MainVerticle.java // Main Verticle
        │                   ├── SubVerticle.java
        │                   ├── common
        │                   │   ├── ApiErrorType.java
        │                   │   ├── ApiRequestCommon.java // API Request
        │                   │   └── ApiResponseCommon.java // API Response
        │                   ├── factory
        │                   │   ├── MyBatisConnectionFactory.java // MyBatis Connection
        │                   │   └── VertxSqlConnectionFactory.java // Vertx JDBC Client Connection
        │                   ├── mysqlBinlog
        │                   │   ├── BinLogClientVerticle.java
        │                   │   ├── BinlogEventType.java
        │                   │   └── SchemaService.java
        │                   ├── query
        │                   │   ├── QueryModule.java
        │                   │   ├── QueryServiceImp.java // Query Getter Using Mybatis
        │                   │   └── QueryServices.java
        │                   ├── secure
        │                   │   ├── CryptoManager.java
        │                   │   ├── CryptoModule.java
        │                   │   └── CryptoService.java
        │                   └── sql
        │                       ├── EBSqlServiceVerticle.java // eventbus sql verticle
        │                       ├── SqlServiceImp.java // API DB Service implement
        │                       └── SqlServices.java
        ├── js
        │   └── jsVerticle.js
        └── resources
            ├── config
            │   ├── app.properties // application property
            │   ├── db-config.xml // mybatis config
            │   ├── db.properties // db connection information property
            │   ├── db.properties.SAMPLE
            │   ├── keystore.jceks
            │   ├── pubsub-mysql-server.json // mysql pubsub server connection config
            │   └── pubsub-mysql-service.json // mysql pubsub service config
            ├── log4j2.xml // log4j2 log
            ├── mapper
            │   ├── test.xml // mybatis mapper xml
            │   └── users.xml
            ├── vertx-default-jul-logging.properties // JUL log (not use in this project)
            └── webroot
                ├── dbRTC.js
                ├── index.html // API Service Test Page (http://localhost:18080)
                ├── sha256.js
                └── ws-test.html
}

Installation

For Linux

Build

$ cd bin
$ ./config-to-server.sh # That's because the author's development machine is Windows.
$ ./build.sh

Run

$ cd bin
$ ./run.sh [start/stop/status] # execute vertx-fat.jar

For Windows

Build

> mvn install
> mvn clean package -f ./pom.xml

Run

> run.bat # execute vertx-fat.jar

See http://localhost:18080

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].