Skip to content

Commit

Permalink
Merge pull request #9732 from aguibert/reactive-db2-client
Browse files Browse the repository at this point in the history
Reactive db2 client
  • Loading branch information
Sanne authored Jun 4, 2020
2 parents edb4629 + c96108b commit 520103f
Show file tree
Hide file tree
Showing 30 changed files with 926 additions and 15 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/ci-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ on:
env:
# Workaround testsuite locale issue
LANG: en_US.UTF-8
NATIVE_TEST_MAVEN_OPTS: "-B --settings .github/mvn-settings.xml --fail-at-end -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11 -Dtest-postgresql -Dtest-elasticsearch -Dtest-keycloak -Dtest-amazon-services -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dnative-image.xmx=5g -Dnative -Dformat.skip install"
JVM_TEST_MAVEN_OPTS: "-e -B --settings .github/mvn-settings.xml -Dtest-postgresql -Dtest-elasticsearch -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dtest-keycloak -Dformat.skip"
NATIVE_TEST_MAVEN_OPTS: "-B --settings .github/mvn-settings.xml --fail-at-end -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:19.3.1-java11 -Dtest-postgresql -Dtest-elasticsearch -Dtest-keycloak -Dtest-amazon-services -Dtest-db2 -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dnative-image.xmx=5g -Dnative -Dformat.skip install"
JVM_TEST_MAVEN_OPTS: "-e -B --settings .github/mvn-settings.xml -Dtest-postgresql -Dtest-elasticsearch -Dtest-db2 -Dtest-mysql -Dtest-mariadb -Dmariadb.base_url='jdbc:mariadb://localhost:3308' -Dmariadb.url='jdbc:mariadb://localhost:3308/hibernate_orm_test' -Dtest-mssql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-kafka -Dtest-keycloak -Dformat.skip"
DB_USER: hibernate_orm_test
DB_PASSWORD: hibernate_orm_test
DB_NAME: hibernate_orm_test
Expand Down Expand Up @@ -182,6 +182,14 @@ jobs:
netstat -ln
sudo service mysql stop || true
docker run --rm --publish 127.0.0.1:3306:3306 --name build-mysql -e MYSQL_USER=$DB_USER -e MYSQL_PASSWORD=$DB_PASSWORD -e MYSQL_DATABASE=$DB_NAME -e MYSQL_RANDOM_ROOT_PASSWORD=true -e MYSQL_DATABASE=hibernate_orm_test -d mysql:5 --skip-ssl
- name: Start DB2
# Cannot run as service becuase the service schema does not support --privileged mode
shell: bash
run: |
docker run --rm --publish 50000:50000 --name build-db2 --privileged=true \
-e DB2INSTANCE=hreact -e DB2INST1_PASSWORD=hreact -e DBNAME=hreact -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false \
-d ibmcom/db2:11.5.0.0a
- uses: actions/checkout@v2

- name: apt clean
Expand Down Expand Up @@ -324,14 +332,16 @@ jobs:
jpa-without-entity
hibernate-tenancy
- category: Data2
db2: "true"
mysql: "true"
postgres: "true"
timeout: 35
timeout: 45
test-modules: >
jpa
jpa-postgresql
jpa-mysql
reactive-mysql-client
reactive-db2-client
- category: Data3
postgres: "true"
timeout: 60
Expand Down Expand Up @@ -476,6 +486,12 @@ jobs:
-e MYSQL_USER=$DB_USER -e MYSQL_PASSWORD=$DB_PASSWORD -e MYSQL_DATABASE=$DB_NAME -e MYSQL_RANDOM_ROOT_PASSWORD=true \
-d mysql:5 --skip-ssl
if: matrix.mysql
- name: DB2 Service
run: |
docker run --rm --publish 50000:50000 --name build-db2 --privileged=true \
-e DB2INSTANCE=hreact -e DB2INST1_PASSWORD=hreact -e DBNAME=hreact -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false \
-d ibmcom/db2:11.5.0.0a
if: matrix.db2
- name: Maria DB Service
run: |
docker run --rm --publish 3308:3306 --name build-mariadb \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/native-cron-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
run: mvn -B install -DskipTests -DskipITs -Dformat.skip

- name: Run integration tests in native
run: mvn -B --settings .github/mvn-settings.xml verify -f integration-tests/pom.xml --fail-at-end -Dno-format -Ddocker -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java${{ matrix.java }} -Dtest-postgresql -Dtest-elasticsearch -Dtest-mysql -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-keycloak -Dtest-kafka -Dtest-mssql -Dtest-mariadb -Dmariadb.url="jdbc:mariadb://localhost:3308/hibernate_orm_test"
run: mvn -B --settings .github/mvn-settings.xml verify -f integration-tests/pom.xml --fail-at-end -Dno-format -Ddocker -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java${{ matrix.java }} -Dtest-postgresql -Dtest-elasticsearch -Dtest-mysql -Dtest-db2 -Dtest-amazon-services -Dtest-vault -Dtest-neo4j -Dtest-keycloak -Dtest-kafka -Dtest-mssql -Dtest-mariadb -Dmariadb.url="jdbc:mariadb://localhost:3308/hibernate_orm_test"

- name: Report
if: always()
Expand Down
5 changes: 5 additions & 0 deletions bom/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@
<artifactId>quarkus-reactive-datasource-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-db2-client-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-pg-client-deployment</artifactId>
Expand Down
12 changes: 11 additions & 1 deletion bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<jboss-logging.version>3.3.2.Final</jboss-logging.version>
<mutiny.version>0.5.2</mutiny.version>
<axle-client.version>0.0.16</axle-client.version>
<mutiny-client.version>0.0.16</mutiny-client.version>
<mutiny-client.version>0.1.0</mutiny-client.version>
<kafka2.version>2.5.0</kafka2.version>
<debezium.version>1.1.2.Final</debezium.version>
<zookeeper.version>3.5.7</zookeeper.version>
Expand Down Expand Up @@ -714,6 +714,11 @@
<artifactId>quarkus-reactive-datasource</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-db2-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-pg-client</artifactId>
Expand Down Expand Up @@ -2593,6 +2598,11 @@
<artifactId>smallrye-axle-mysql-client</artifactId>
<version>${axle-client.version}</version>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-mutiny-vertx-db2-client</artifactId>
<version>${mutiny-client.version}</version>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-mutiny-vertx-mysql-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public final class FeatureBuildItem extends MultiBuildItem {
public static final String MUTINY = "mutiny";
public static final String NARAYANA_JTA = "narayana-jta";
public static final String NARAYANA_STM = "narayana-stm";
public static final String REACTIVE_DB2_CLIENT = "reactive-db2-client";
public static final String REACTIVE_PG_CLIENT = "reactive-pg-client";
public static final String REACTIVE_MYSQL_CLIENT = "reactive-mysql-client";
public static final String NEO4J = "neo4j";
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/asciidoc/credentials-provider.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Currently, the `Credentials Provider` interface is implemented by the `vault` ex
by the following credentials consumer extensions:

* `agroal`
* `reactive-db2-client`
* `reactive-mysql-client`
* `reactive-pg-client`
Expand Down
22 changes: 15 additions & 7 deletions docs/src/main/asciidoc/datasource.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ quarkus.datasource.jdbc.max-size=16

=== Reactive datasource

Add either the `reactive-pg-client` or the `reactive-mysql-client` extension.
Add the correct reactive extension for the database you are using: `reactive-pg-client`, `reactive-mysql-client`, or `reactive-db2-client`.

Then configure your reactive datasource:

Expand Down Expand Up @@ -89,6 +89,7 @@ The database kind defines which type of database you will connect to.

We currently include these built-in database kinds:

* DB2: `db2` (reactive only)
* Derby: `derby`
* H2: `h2`
* MariaDB: `mariadb`
Expand Down Expand Up @@ -284,16 +285,19 @@ Because of this, you can also use `javax.sql.DataSource` as the injected type.

=== Reactive datasource

If you prefer using a reactive datasource, Quarkus offers MySQL/MariaDB and PostgreSQL reactive clients.
If you prefer using a reactive datasource, Quarkus offers DB2, MySQL/MariaDB, and PostgreSQL reactive clients.

==== Install the Maven dependencies

Depending on whether you wish to use MySQL/MariaDB or PostgreSQL, you need to add either the `quarkus-reactive-pg-client`
or the `quarkus-reactive-mysql-client` extension.
Depending on which database you want to use, add the corresponding extension:

* DB2: `quarkus-reactive-db2-client`
* MySQL/MariaDB: `quarkus-reactive-mysql-client`
* PostgreSQL: `quarkus-reactive-pg-client`

The installed extension must be consistent with the `quarkus.datasource.db-kind` you define in your datasource configuration.

==== Configure the JDBC datasource
==== Configure the reactive datasource

Once the driver is there, you just need to configure the connection URL.

Expand All @@ -305,7 +309,7 @@ quarkus.datasource.reactive.url=postgresql:///your_database
quarkus.datasource.reactive.max-size=20
----

=== Both
=== JDBC and reactive datasources simultaneously

By default, if you include both a JDBC extension (+ Agroal) and a reactive datasource extension handling the given database kind,
both will be created.
Expand Down Expand Up @@ -400,7 +404,7 @@ AgroalDataSource inventoryDataSource;

== Datasource Health Check

If you are using the `quarkus-smallrye-health` extension, `quarkus-agroal`, `quarkus-reactive-pg-client` and `quarkus-reactive-mysql-client` extensions will automatically add a readiness health check
If you are using the `quarkus-smallrye-health` extension, the `quarkus-agroal` and reactive client extensions will automatically add a readiness health check
to validate the datasource.

So when you access the `/health/ready` endpoint of your application you will have information about the datasource validation status.
Expand Down Expand Up @@ -565,6 +569,10 @@ You can find more information at the https://db.apache.org/derby/docs/10.8/devgu

include::{generated-dir}/config/quarkus-reactive-datasource.adoc[opts=optional, leveloffset=+1]

=== Reactive DB2 Configuration

include::{generated-dir}/config/quarkus-reactive-db2-client.adoc[opts=optional, leveloffset=+1]

=== Reactive MariaDB/MySQL Specific Configuration

include::{generated-dir}/config/quarkus-reactive-mysql-client.adoc[opts=optional, leveloffset=+1]
Expand Down
15 changes: 12 additions & 3 deletions docs/src/main/asciidoc/reactive-sql-clients.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include::./attributes.adoc[]
The Reactive SQL Clients have a straightforward API focusing on scalability and low-overhead.
Currently, the following database servers are supported:

* DB2
* PostgreSQL
* MariaDB/MySQL
Expand Down Expand Up @@ -462,13 +463,17 @@ Navigate to http://localhost:8080/fruits.html and read/create/delete some fruits
|===
|Database |Extension name |Pool class name

|PostgreSQL
|`quarkus-reactive-pg-client`
|`io.vertx.mutiny.pgclient.PgPool`
|DB2
|`quarkus-reactive-db2-client`
|`io.vertx.mutiny.db2client.DB2Pool`

|MariaDB/MySQL
|`quarkus-reactive-mysql-client`
|`io.vertx.mutiny.mysqlclient.MySQLPool`

|PostgreSQL
|`quarkus-reactive-pg-client`
|`io.vertx.mutiny.pgclient.PgPool`
|===

== Transactions
Expand Down Expand Up @@ -533,6 +538,10 @@ include::{generated-dir}/config/quarkus-datasource.adoc[opts=optional, leveloffs

include::{generated-dir}/config/quarkus-reactive-datasource.adoc[opts=optional, leveloffset=+1]

=== DB2

include::{generated-dir}/config/quarkus-reactive-db2-client.adoc[opts=optional, leveloffset=+1]

=== MariaDB/MySQL

include::{generated-dir}/config/quarkus-reactive-mysql-client.adoc[opts=optional, leveloffset=+1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
public final class DatabaseKind {

public static final String DB2 = "db2";
public static final String DERBY = "derby";
public static final String H2 = "h2";
public static final String MARIADB = "mariadb";
Expand Down Expand Up @@ -50,6 +51,10 @@ public static String normalize(String value) {
return lowerCaseValue;
}

public static boolean isDB2(String value) {
return is(value, DB2);
}

public static boolean isDerby(String value) {
return is(value, DERBY);
}
Expand Down Expand Up @@ -88,6 +93,7 @@ private DatabaseKind() {
}

private enum SupportedDatabaseKind {
DB2(DatabaseKind.DB2),
DERBY(DatabaseKind.DERBY),
H2(DatabaseKind.H2),
MARIADB(DatabaseKind.MARIADB),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DatabaseKindTest {

@Test
public void testNormalize() {
assertEquals(DatabaseKind.DB2, DatabaseKind.normalize("db2"));
assertEquals(DatabaseKind.DERBY, DatabaseKind.normalize("derby"));
assertEquals(DatabaseKind.H2, DatabaseKind.normalize("h2"));
assertEquals(DatabaseKind.MARIADB, DatabaseKind.normalize("mariadb"));
Expand All @@ -28,6 +29,9 @@ public void testNormalize() {

@Test
public void testIs() {
assertTrue(DatabaseKind.isDB2("db2"));
assertFalse(DatabaseKind.isDB2("mariadb"));

assertTrue(DatabaseKind.isDerby("derby"));
assertFalse(DatabaseKind.isDerby("mariadb"));

Expand Down
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<module>smallrye-reactive-messaging-mqtt</module>
<module>smallrye-context-propagation</module>
<module>reactive-datasource</module>
<module>reactive-db2-client</module>
<module>reactive-pg-client</module>
<module>reactive-mysql-client</module>
<module>mailer</module>
Expand Down
57 changes: 57 additions & 0 deletions extensions/reactive-db2-client/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-db2-client-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<artifactId>quarkus-reactive-db2-client-deployment</artifactId>

<name>Quarkus - Reactive DB2 Client - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-datasource-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-credentials-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-db2-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.reactive.db2.client.deployment;

import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.runtime.RuntimeValue;
import io.vertx.db2client.DB2Pool;

public final class DB2PoolBuildItem extends SimpleBuildItem {

private final RuntimeValue<DB2Pool> db2Pool;

public DB2PoolBuildItem(RuntimeValue<DB2Pool> db2Pool) {
this.db2Pool = db2Pool;
}

public RuntimeValue<DB2Pool> getDB2Pool() {
return db2Pool;
}

}
Loading

0 comments on commit 520103f

Please sign in to comment.