Quarkus Jnosql

Introduction

The Quarkus NoSQL Extension facilitates seamless interaction between Quarkus and Eclipse JNoSQL, enabling easy integration with various NoSQL databases in Quarkus applications. By following the steps outlined in this documentation, Quarkus developers can effortlessly incorporate Eclipse JNoSQL into their projects, simplifying NoSQL database interactions and empowering the development of efficient and scalable applications. Eclipse JNoSQL adheres to two essential Jakarta EE specifications: Jakarta Data and Jakarta NoSQL.

Jakarta NoSQL is a Java framework designed to streamline the integration of Java applications with various NoSQL databases. It offers a consistent and easy-to-use API, allowing developers to interact with different NoSQL databases seamlessly.

On the other hand, the Jakarta Data specification provides an API for simplified data access to various database types, including relational and NoSQL databases. Java developers can access these repositories through multiple methods, such as composing custom queries on a Repository interface.

Integrating Eclipse JNoSQL into Quarkus projects ensures adherence to these Jakarta EE standards and leverages the benefits of standardized APIs for enhanced productivity and maintainability.

Why Use Quarkus JNoSQL Extension?

The Quarkus NoSQL Extension offers several advantages for developers:

  • Simplified NoSQL Integration: Abstracts the complexity of working with different NoSQL databases, providing a consistent API regardless of the underlying technology. Facilitates easy switching between databases or using multiple databases in a single application.

  • Type-Safe Queries: Empowers developers to write database queries using Java code rather than raw query strings, improving code readability and catching errors at compile-time.

  • Seamless Quarkus Integration: Utilizes Quarkus' fast startup times and efficient resource utilization while working with NoSQL databases, ensuring lightweight and responsive applications.

  • Database Agnosticism: Supports a wide range of NoSQL databases, including key-value stores, document databases, and column-family stores. Offers flexibility to choose the most suitable database for specific use cases without major code changes.

  • Rich Documentation and Ecosystem: Eclipse JNoSQL boasts a thriving community and comprehensive documentation, making it easy for developers to find support, tutorials, and examples. Integration with Quarkus allows tapping into the vibrant Quarkus ecosystem as well.

Installation

To use this extension, add the io.quarkiverse.jnosql:quarkus-jnosql extension to your build file. For instance, with Maven, include the following dependency in your POM file:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql</artifactId>
    <version>3.2.2.1</version>
</dependency>

Getting Started

Getting started with Quarkus JNoSQL is straightforward:

  1. Add the Quarkus JNoSQL Extension to your project’s dependencies. You can find the latest version on Maven Central.

  2. Define your entities using JNoSQL annotations. For example:

import jakarta.nosql.Column;
import jakarta.nosql.Entity;
import jakarta.nosql.Id;

@Entity
public class TestEntity {

   @Id
   private String id;

   @Column
   private String testField;
}

Key-Value Database Configuration

Configuration

Configure the JNoSql KeyValue Quarkus extension by specifying the name of the database that will be utilized within the Eclipse JNoSQL framework in your application.properties:

jnosql.keyvalue.database=my-database-name

Usage

Inject the KeyValueTemplate into your class and use it to interact with the KeyValue database:

import jakarta.inject.Inject;
import org.jnosql.artemis.key.KeyValueTemplate;

@Inject
private KeyValueTemplate template;

public void insert(TestEntity entity) {
    template.insert(entity);
}

Key-Value Database Specific Configuration

When configuring databases for use with Quarkus and Eclipse JNoSQL, it’s important to note that instead of using the traditional Eclipse JNoSQL properties and configuration, Quarkus provides its properties and configuration for seamless integration. Below are sections detailing the configuration specifics for different NoSQL databases within the Quarkus environment.

The forthcoming sections will delve into the configuration details for ArangoDB, DynamoDB, Hazelcast, and Redis databases, providing comprehensive guidance for each.

ArangoDB

Add the ArangoDB dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-keyvalue-arangodb</artifactId>
</dependency>

For specific configuration details, please refer to the ArangoDB JNoSQL driver.

DynamoDB

Add the DynamoDB dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-keyvalue-dynamodb</artifactId>
</dependency>

Please refer to the DynamoDB Quarkiverse extension for specific configuration details.

Hazelcast

Add the Hazelcast dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-keyvalue-hazelcast</artifactId>
</dependency>

Please refer to the Quarkus Hazelcast extension for specific configuration details.

Redis

Add the Redis dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-keyvalue-redis</artifactId>
</dependency>

For specific configuration details, please refer to the Redis Quarkus extension.

Document Database Configuration

Configuration

Configure the JNoSql Document Quarkus extension by specifying the database’s name in your application.properties:

jnosql.document.database=my-database-name

Usage

Inject the DocumentTemplate into your class and use it to interact with the Document database:

import jakarta.inject.Inject;
import org.jnosql.artemis.document.DocumentTemplate;

@Inject
private DocumentTemplate template;

public void insert(TestDocumentEntity entity) {
    template.insert(entity);
}

Document Database Specific Configuration

When configuring databases for use with Quarkus and Eclipse JNoSQL, it’s important to note that instead of using the traditional Eclipse JNoSQL properties and configuration, Quarkus provides its properties and configuration for seamless integration. Below are sections detailing the configuration specifics for different NoSQL databases within the Quarkus environment.

The forthcoming sections will delve into the configuration details for ArangoDB, CouchDB, Elasticsearch, MongoDB, and Solr databases, providing comprehensive guidance for each.

ArangoDB

Add the ArangoDB dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-document-arangodb</artifactId>
</dependency>

For specific configuration details, please refer to the ArangoDB JNoSQL driver.

CouchDB

Add the CouchDB dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-document-couchdb</artifactId>
</dependency>

For specific configuration details, please refer to the CouchDB JNoSQL driver.

Elasticsearch

Add the Elasticsearch dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-document-elasticsearch</artifactId>
</dependency>

For specific configuration details, please refer to the ElasticSearch driver.

MongoDB

Add the MongoDB dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-document-mongodb</artifactId>
</dependency>

For specific configuration details, please refer to the MongoDB configuration.

Solr

Add the Solr dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-document-solr</artifactId>
</dependency>

For specific configuration details, please refer to the Solr JNoSQL driver.

Column Database Configuration

Configuration

Configure the JNoSql Column Quarkus extension by specifying the database’s name in your application.properties:

jnosql.column.database=my-database-name

Usage

Inject the ColumnTemplate into your class and use it to interact with the Column database:

import jakarta.inject.Inject;
import org.jnosql.artemis.column.ColumnTemplate;

@Inject
private ColumnTemplate template;

public void insert(TestColumnEntity entity) {
    template.insert(entity);
}

Column Database Specific Configuration

Cassandra

Add the Cassandra dependency to your project’s pom.xml:

<dependency>
    <groupId>io.quarkiverse.jnosql</groupId>
    <artifactId>quarkus-jnosql-column-cassandra</artifactId>
</dependency>

Please refer to the Cassandra Quarkus extension for specific configuration details.