Skip to content

Commit ba9d94c

Browse files
committed
Integrate/AMQP: Add entry point page, micro tutorial, and category item
1 parent 01fa3fa commit ba9d94c

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

docs/ingest/etl/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ Load data from database systems.
132132

133133

134134
::::{grid-item-card} {material-outlined}`fast_forward;2em` Streams
135+
136+
- {ref}`amqp`
137+
138+
The AMQP protocol is an open standard application layer protocol for
139+
message-oriented middleware. The defining features of AMQP are message
140+
orientation, queuing, routing (including point-to-point and
141+
publish-and-subscribe), reliability, and security.
142+
135143
- {ref}`kafka`
136144

137145
Apache Kafka is an open-source distributed event streaming platform

docs/integrate/amqp/index.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
(amqp)=
2+
# AMQP
3+
4+
```{div} .float-right
5+
[![AMQP logo](https://www.cleo.com/sites/default/files/styles/desktop_664_270_scale/public/2023-12/amqp-logo.png.webp){width=180px loading=lazy}][AMQP]
6+
```
7+
```{div} .clearfix
8+
```
9+
10+
:::{rubric} About
11+
:::
12+
13+
The [AMQP] protocol is an open standard application layer protocol for
14+
message-oriented middleware. The defining features of AMQP are message
15+
orientation, queuing, routing (including point-to-point and
16+
publish-and-subscribe), reliability, and security.
17+
18+
:::{rubric} Synopsis
19+
:::
20+
21+
Use LorryStream to receive JSON data from an AMQP queue, continuously loading
22+
records into CrateDB.
23+
```shell
24+
uvx --from=lorrystream lorry relay \
25+
"amqp://guest:guest@localhost:5672/%2F?queue=testdrive&content-type=json" \
26+
"crate://localhost/?table=testdrive"
27+
```
28+
29+
:::{rubric} Learn
30+
:::
31+
32+
[LorryStream] is a lightweight and polyglot stream-processing library, used as a
33+
data backplane, message relay, or pipeline subsystem.
34+
35+
::::{grid}
36+
37+
:::{grid-item-card} Tutorial: Use LorryStream
38+
:link: amqp-tutorial
39+
:link-type: ref
40+
How to load data from AMQP into CrateDB using LorryStream.
41+
:::
42+
43+
::::
44+
45+
:::{toctree}
46+
:maxdepth: 1
47+
:hidden:
48+
Tutorial <tutorial>
49+
:::
50+
51+
52+
[LorryStream]: https://lorrystream.readthedocs.io/
53+
[AMQP]: https://www.amqp.org/

docs/integrate/amqp/tutorial.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
(amqp-tutorial)=
2+
3+
# Load data from an AMQP queue into CrateDB
4+
5+
The tutorial will walk you through starting the [RabbitMQ] AMQP broker
6+
and CrateDB, publishing JSON data to an AMQP queue, consuming and relaying
7+
it into a CrateDB table continuously, and validating that the data has
8+
been stored successfully.
9+
The data transfer is supported by the [LorryStream AMQP source] data
10+
pipeline element.
11+
12+
## Prerequisites
13+
14+
Docker is used for running all components. This approach works consistently
15+
across Linux, macOS, and Windows.
16+
17+
Alternatively, you can use Podman. You can also use a different AMQP broker such as
18+
Apache Qpid, Apache ActiveMQ, IBM MQ, or Solace. Azure Event Hubs and Azure Service
19+
Bus speak AMQP as well, but with protocol and authentication specifics; adjust
20+
settings accordingly.
21+
22+
Create a shared network.
23+
```shell
24+
docker network create cratedb-demo
25+
```
26+
27+
Start CrateDB.
28+
```shell
29+
docker run --name=cratedb --rm --network=cratedb-demo \
30+
--publish=4200:4200 --publish=5432:5432 \
31+
--env=CRATE_HEAP_SIZE=2g docker.io/crate -Cdiscovery.type=single-node
32+
```
33+
34+
Start RabbitMQ.
35+
```shell
36+
docker run --name=rabbitmq --rm --network=cratedb-demo \
37+
--publish=5672:5672 docker.io/rabbitmq:3
38+
```
39+
> Note: This broker configuration allows anonymous access for demonstration purposes only.
40+
> Do not expose it to untrusted networks. For production, configure authentication/TLS.
41+
42+
Prepare shortcuts for the CrateDB shell, LorryStream, and the AMQP client
43+
programs.
44+
45+
::::{tab-set}
46+
47+
:::{tab-item} Linux and macOS
48+
To make the settings persistent, add them to your shell profile (e.g., `~/.profile` or `~/.zshrc`).
49+
```shell
50+
alias crash="docker run --rm -it --network=cratedb-demo ghcr.io/crate/cratedb-toolkit crash"
51+
alias lorry="docker run --rm -i --network=cratedb-demo ghcr.io/daq-tools/lorrystream lorry"
52+
alias amqpcat="docker run --rm -i --network=cratedb-demo docker.io/cloudamqp/amqpcat amqpcat"
53+
```
54+
:::
55+
:::{tab-item} Windows PowerShell
56+
To make the settings persistent, add them to your PowerShell profile (`$PROFILE`).
57+
```powershell
58+
function crash { docker run --rm -it --network=cratedb-demo ghcr.io/crate/cratedb-toolkit crash @args }
59+
function lorry { docker run --rm -i --network=cratedb-demo ghcr.io/daq-tools/lorrystream lorry @args }
60+
function amqpcat { docker run --rm -i --network=cratedb-demo docker.io/cloudamqp/amqpcat amqpcat @args }
61+
```
62+
:::
63+
:::{tab-item} Windows Command
64+
```shell
65+
doskey crash=docker run --rm -it --network=cratedb-demo ghcr.io/crate/cratedb-toolkit crash $*
66+
doskey lorry=docker run --rm -i --network=cratedb-demo ghcr.io/daq-tools/lorrystream lorry $*
67+
doskey amqpcat=docker run --rm -i --network=cratedb-demo docker.io/cloudamqp/amqpcat amqpcat $*
68+
```
69+
:::
70+
71+
::::
72+
73+
## Usage
74+
75+
Invoke the data transfer pipeline.
76+
```shell
77+
lorry relay \
78+
"amqp://guest:guest@rabbitmq:5672/%2F?exchange=default&queue=default&routing-key=testdrive&setup=exchange,queue,bind&content-type=json" \
79+
"crate://cratedb/?table=testdrive"
80+
```
81+
82+
Publish a JSON message to AMQP.
83+
```shell
84+
echo '{"temperature": 42.84, "humidity": 83.1}' | \
85+
amqpcat --producer --uri='amqp://guest:guest@rabbitmq:5672/%2F' \
86+
--exchange=default --queue=default --routing-key=testdrive
87+
```
88+
89+
Inspect data stored in CrateDB.
90+
```shell
91+
crash --hosts cratedb -c "SELECT * FROM testdrive"
92+
```
93+
94+
95+
[LorryStream AMQP source]: https://lorrystream.readthedocs.io/source/amqp.html
96+
[RabbitMQ]: https://www.rabbitmq.com/

docs/integrate/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Please also visit the [Overview of CrateDB integration tutorials].
1717
:maxdepth: 1
1818

1919
airflow/index
20+
amqp/index
2021
aws-lambda/index
2122
azure-functions/index
2223
cluvio/index

0 commit comments

Comments
 (0)