{"id":15138637,"url":"https://github.com/maif/jooq-async","last_synced_at":"2025-10-23T15:30:38.729Z","repository":{"id":43791772,"uuid":"297271422","full_name":"MAIF/jooq-async","owner":"MAIF","description":"Use jooq to build queries and run it a reactive way","archived":false,"fork":false,"pushed_at":"2024-10-01T14:43:56.000Z","size":214,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-30T19:11:19.558Z","etag":null,"topics":["jooq","reactive","vertx"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MAIF.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-21T08:09:11.000Z","updated_at":"2024-11-06T08:12:55.000Z","dependencies_parsed_at":"2024-05-16T03:43:23.229Z","dependency_job_id":"af617d21-eaa3-4af8-a252-981445ec3aad","html_url":"https://github.com/MAIF/jooq-async","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIF%2Fjooq-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIF%2Fjooq-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIF%2Fjooq-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAIF%2Fjooq-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MAIF","download_url":"https://codeload.github.com/MAIF/jooq-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237843858,"owners_count":19375218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jooq","reactive","vertx"],"created_at":"2024-09-26T07:42:49.346Z","updated_at":"2025-10-23T15:30:33.322Z","avatar_url":"https://github.com/MAIF.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Reactive jooq API [![ga-badge][]][ga] [![jar-badge][]][jar]\n\n[ga]:               https://github.com/MAIF/jooq-async/actions?query=workflow%3ABuild\n[ga-badge]:         https://github.com/MAIF/jooq-async/workflows/Build/badge.svg\n[jar]:              https://maven-badges.herokuapp.com/maven-central/fr.maif/jooq-async-api\n[jar-badge]:        https://maven-badges.herokuapp.com/maven-central/fr.maif/jooq-async-api/badge.svg\n\nThis API is a solution to use jooq with reactive clients for RDBMS.  \n\n## Implementations \n\nAt the moment there are 2 implementations: \n * a blocking jdbc implementation \n * a vertx reactive implementation for postgresql only \n\n## Import\n\nJcenter hosts this library.\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003efr.maif\u003c/groupId\u003e\n  \u003cartifactId\u003ejooq-async-jdbc\u003c/artifactId\u003e\n    \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nOR\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003efr.maif\u003c/groupId\u003e\n  \u003cartifactId\u003ejooq-async-reactive\u003c/artifactId\u003e\n  \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n``` \n\n### Gradle\n\n```gradle\nimplementation \"fr.maif:jooq-async-api:${version}\"\n```\n\nOR\n\n```gradle\nimplementation \"fr.maif:jooq-async-reactive:${version}\"\n```\n\n## The API \n\n### Create a pool \n\nThe JDBC one : \n\n```java\nPGSimpleDataSource dataSource = new PGSimpleDataSource();\ndataSource.setUrl(url);\ndataSource.setUser(user);\ndataSource.setPassword(password);\nPgAsyncPool jdbcPgAsyncPool = new JdbcPgAsyncPool(SQLDialect.POSTGRES, dataSource, Executors.newFixedThreadPool(5));\n```\n\nThe reactive one : \n\n```java\nDefaultConfiguration jooqConfig = new DefaultConfiguration();\njooqConfig.setSQLDialect(SQLDialect.POSTGRES);\nPgConnectOptions options = new PgConnectOptions()\n        .setPort(port)\n        .setHost(host)\n        .setDatabase(database)\n        .setUser(user)\n        .setPassword(password);\nPoolOptions poolOptions = new PoolOptions().setMaxSize(10);\nVertx vertx = Vertx.vertx();\nPool client = PgBuilder.pool()\n        .using(vertx)\n        .connectingTo(options)\n        .with(poolOptions)\n        .build();\n\nPgAsyncPool reactivePgAsyncPool = new ReactivePgAsyncPool(client, jooqConfig);\n```\n\n### Perform query \n\nThe idea is to use the jooq DSL as a builder to write the query. The query is then run against the underlying library.  \n\n#### Query one : \n\n```java\nCompletionStage\u003cOption\u003cString\u003e\u003e futureResult = reactivePgAsyncPool\n        .queryOne(dsl -\u003e dsl.select(name).from(table).where(name.eq(\"Ragnar\")))\n        .map(mayBeResult -\u003e mayBeResult.map(row -\u003e row.get(name)));\n```\n\n#### Query many : \n\n```java\nCompletionStage\u003cList\u003cString\u003e\u003e futureResult = reactivePgAsyncPool\n        .query(dsl -\u003e dsl.select(name).from(table)))\n        .map(results -\u003e results.map(row -\u003e row.get(name)));\n```\n\n#### Stream data \n\n```java\nPublisher\u003cString, NotUsed\u003e stream = reactivePgAsyncPool\n                .stream(500 /*fetch size*/, dsl -\u003e dsl.select(name).from(table))\n                .map(q -\u003e q.get(name));\n```\n\nThe publisher comes from the reactive streams API. \n\n#### Execute statement\n\n```java \nCompletionStage\u003cInteger\u003e insertResult = reactivePgAsyncPool.inTransaction(t -\u003e\n        t.execute(dsl -\u003e dsl.insertInto(table).set(name, \"test\"))\n);\n``` \n\n#### Batch statements\n\nWith this version you can send a statement once and then send all parameters. \nThis version is the most performant if you have one statement with multiple values. \n\n```java\nList\u003cString\u003e names = List.range(0, 10).map(i -\u003e \"name-\" + i);\nCompletionStage\u003cLong\u003e batchResult = reactivePgAsyncPool.executeBatch(\n        dsl -\u003e dslContext.insertInto(table).columns(name).values((String) null),\n        names.map(List::of)\n);\n```\n\nWith this version, you can batch a set of statements. You should use this version if your statements are all different. \n\n```java\nList\u003cString\u003e names = List.range(0, 10).map(i -\u003e \"name-\" + i);\nCompletionStage\u003cLong\u003e batchResult = reactivePgAsyncPool.executeBatch(dsl -\u003e\n        names.map(n -\u003e dslContext.insertInto(table).set(name, n))\n);\n```\n\n## Spring reactor :\n\nThe `jooq-async-reactive` module expose operations with the `Mono` / `Flux` API. \n\n```java\nPgAsyncPool pgAsyncPool = PgAsyncPool.create(client, jooqConfig);\n\nMono\u003cOption\u003cString\u003e\u003e result =  pgAsyncPool.queryOneOne(dsl -\u003e dsl\n            .select(name)\n            .from(table)\n            .where(name.eq(\"Ragnar\"))\n        )\n        .map(mayBeResult -\u003e mayBeResult.map(row -\u003e row.get(name)));\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaif%2Fjooq-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaif%2Fjooq-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaif%2Fjooq-async/lists"}