Skip to content

Latest commit

 

History

History
 
 

artemis-elasticsearch

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Artemis to ElasticSearch: A Camel Quarkus example

{cq-description}

This example shows how to connect ActiveMQ Broker to Elasticsearch service, create index and send data to it.

Tip
Check the Camel Quarkus User guide for prerequisites and other general information.

Prerequisites:

In order to send a message from Artemis Broker to Elasticsearch you need to start two services:

1) ActiveMQ Artemis - message broker that is connected to a paho client.

2) Elasticsearch - database that stores your data.

You can also use podman instead of docker for all the steps below.

Run the containers:

Run the Artemis container:

docker run -d --rm -e AMQ_EXTRA_ARGS="--relax-jolokia" -e AMQ_USER=admin -e AMQ_PASSWORD=admin -p 61616:61616 -p 8161:8161 -p 1883:1883 --name artemis quay.io/artemiscloud/activemq-artemis-broker:1.0.26

Now you can access Artemis on localhost:8161

Run the Elasticsearch container:

docker run -d --rm --name elasticsearch -p 9200:9200 -p 9300:9300 -it -m 4GB -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.io/elastic/elasticsearch:8.13.2

Now you can access Elasticsearch on localhost:9200

Start in the Development mode

mvn clean compile quarkus:dev

Package and run the application

Once you are done with developing you may want to package and run the application.

Tip
Find more details about the JVM mode and Native mode in the Package and run section of Camel Quarkus User guide

JVM mode:

mvn clean package
java -jar target/quarkus-app/quarkus-run.jar

Native mode

Important
Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section of Camel Quarkus User guide.

To prepare a native executable using GraalVM, run the following command:

mvn clean package -Pnative
./target/*-runner

Send and retrieve messages:

Send a message to the Artemis broker:

curl -d 'my cool device' -H 'Content-Type: text/plain' localhost:8080/devices
Note
You may need to wait a few seconds for the data to be persisted before it can be retrieved.

Retrieve from Elasticsearch:

curl localhost:8080/devices

Stop the containers:

docker stop elasticsearch
docker stop artemis

Feedback

Please report bugs and propose improvements via GitHub issues of Camel Quarkus project.