-
Notifications
You must be signed in to change notification settings - Fork 1
Integrate/AMQP: Add entry point page, micro tutorial, and category item #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| (amqp)= | ||
| # AMQP | ||
|
|
||
| ```{div} .float-right | ||
| [{width=180px loading=lazy}][AMQP] | ||
| ``` | ||
| ```{div} .clearfix | ||
| ``` | ||
|
|
||
| :::{rubric} About | ||
| ::: | ||
|
|
||
| The [AMQP] protocol is an open standard application layer protocol for | ||
| message-oriented middleware. The defining features of AMQP are message | ||
| orientation, queuing, routing (including point-to-point and | ||
| publish-and-subscribe), reliability, and security. | ||
|
|
||
| :::{rubric} Synopsis | ||
| ::: | ||
|
|
||
| Use LorryStream to receive JSON data from an AMQP queue, continuously loading | ||
| records into CrateDB. | ||
| ```shell | ||
| uvx --from=lorrystream lorry relay \ | ||
| "amqp://guest:guest@localhost:5672/%2F?queue=testdrive&content-type=json" \ | ||
| "crate://localhost/?table=testdrive" | ||
| ``` | ||
amotl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| :::{rubric} Learn | ||
| ::: | ||
|
|
||
| [LorryStream] is a lightweight and polyglot stream-processing library, used as a | ||
| data backplane, message relay, or pipeline subsystem. | ||
|
|
||
| ::::{grid} | ||
|
|
||
| :::{grid-item-card} Tutorial: Use LorryStream | ||
| :link: amqp-tutorial | ||
| :link-type: ref | ||
| How to load data from AMQP into CrateDB using LorryStream. | ||
| ::: | ||
|
|
||
| :::: | ||
|
|
||
| :::{toctree} | ||
| :maxdepth: 1 | ||
| :hidden: | ||
| Tutorial <tutorial> | ||
| ::: | ||
|
|
||
|
|
||
| [LorryStream]: https://lorrystream.readthedocs.io/ | ||
| [AMQP]: https://www.amqp.org/ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume the link is correct as Wikipedia also points to it. Currently, the website has a configuration error 🤯. This comment is safe to ignore 😄
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oha. It worked yesterday, and hopefully it will start working again soon.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the link checker still needed a fix. 926e28a it is. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| (amqp-tutorial)= | ||
|
|
||
| # Load data from an AMQP queue into CrateDB | ||
|
|
||
| The tutorial will walk you through starting the [RabbitMQ] AMQP broker | ||
| and CrateDB, publishing JSON data to an AMQP queue, consuming and relaying | ||
| it into a CrateDB table continuously, and validating that the data has | ||
| been stored successfully. | ||
| The data transfer is supported by the [LorryStream AMQP source] data | ||
| pipeline element. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Docker is used for running all components. This approach works consistently | ||
| across Linux, macOS, and Windows. | ||
|
|
||
| Alternatively, you can use Podman. You can also use a different AMQP broker such as | ||
| Apache Qpid, Apache ActiveMQ, IBM MQ, or Solace. Azure Event Hubs and Azure Service | ||
| Bus speak AMQP as well, but with protocol and authentication specifics; adjust | ||
| settings accordingly. | ||
|
|
||
| Create a shared network. | ||
| ```shell | ||
| docker network create cratedb-demo | ||
| ``` | ||
|
|
||
| Start CrateDB. | ||
| ```shell | ||
| docker run --name=cratedb --rm --network=cratedb-demo \ | ||
| --publish=4200:4200 --publish=5432:5432 \ | ||
| --env=CRATE_HEAP_SIZE=2g docker.io/crate -Cdiscovery.type=single-node | ||
| ``` | ||
|
|
||
| Start RabbitMQ. | ||
| ```shell | ||
| docker run --name=rabbitmq --rm --network=cratedb-demo \ | ||
| --publish=5672:5672 docker.io/rabbitmq:3 | ||
| ``` | ||
| > Note: This broker configuration allows anonymous access for demonstration purposes only. | ||
| > Do not expose it to untrusted networks. For production, configure authentication/TLS. | ||
|
Comment on lines
+36
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guest user cannot connect remotely; secure RabbitMQ and avoid exposing 5672 unnecessarily. By default, RabbitMQ disallows remote connections for the Apply these diffs: -docker run --name=rabbitmq --rm --network=cratedb-demo \
- --publish=5672:5672 docker.io/rabbitmq:3
+docker run --name=rabbitmq --rm --network=cratedb-demo \
+ -e RABBITMQ_DEFAULT_USER=crate \
+ -e RABBITMQ_DEFAULT_PASS=crate \
+ -e RABBITMQ_DEFAULT_VHOST=/ \
+ docker.io/rabbitmq:3
-> Note: This broker configuration allows anonymous access for demonstration purposes only.
-> Do not expose it to untrusted networks. For production, configure authentication/TLS.
+> Note: This example uses plaintext credentials and no TLS for demo purposes only.
+> Do not expose the broker to untrusted networks. For production, use non-default
+> credentials, enable TLS, and restrict network access.-lorry relay \
- "amqp://guest:guest@rabbitmq:5672/%2F?exchange=default&queue=default&routing-key=testdrive&setup=exchange,queue,bind&content-type=json" \
- "crate://cratedb/?table=testdrive"
+lorry relay \
+ "amqp://crate:crate@rabbitmq:5672/%2F?exchange=default&queue=default&routing-key=testdrive&setup=exchange,queue,bind&content-type=json" \
+ "crate://cratedb/?table=testdrive"-echo '{"temperature": 42.84, "humidity": 83.1}' | \
- amqpcat --producer --uri='amqp://guest:guest@rabbitmq:5672/%2F' \
+echo '{"temperature": 42.84, "humidity": 83.1}' | \
+ amqpcat --producer --uri='amqp://crate:crate@rabbitmq:5672/%2F' \
--exchange=default --queue=default --routing-key=testdriveAlso applies to: 78-80, 83-87 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai: This is a code example / tech demo, with a different focus than on security, like many code snippets in this repository. Please remember to be more lenient about such details in this very context in the future -- thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @amotl, understood! You're absolutely right - in the context of tutorials and tech demos, simplicity and ease of following along should take precedence over security hardening. I'll be more mindful of this balance in educational content, focusing my suggestions on the core functionality rather than production-ready security practices. The current approach with guest credentials and straightforward setup makes perfect sense for helping users quickly grasp the AMQP integration concepts without getting bogged down in security configuration details. Thanks for the clarification about the repository's documentation philosophy! ✏️ Learnings added
|
||
| Prepare shortcuts for the CrateDB shell, LorryStream, and the AMQP client | ||
| programs. | ||
|
|
||
| ::::{tab-set} | ||
|
|
||
| :::{tab-item} Linux and macOS | ||
| To make the settings persistent, add them to your shell profile (e.g., `~/.profile` or `~/.zshrc`). | ||
| ```shell | ||
| alias crash="docker run --rm -it --network=cratedb-demo ghcr.io/crate/cratedb-toolkit crash" | ||
| alias lorry="docker run --rm -i --network=cratedb-demo ghcr.io/daq-tools/lorrystream lorry" | ||
| alias amqpcat="docker run --rm -i --network=cratedb-demo docker.io/cloudamqp/amqpcat amqpcat" | ||
| ``` | ||
| ::: | ||
| :::{tab-item} Windows PowerShell | ||
| To make the settings persistent, add them to your PowerShell profile (`$PROFILE`). | ||
| ```powershell | ||
| function crash { docker run --rm -it --network=cratedb-demo ghcr.io/crate/cratedb-toolkit crash @args } | ||
| function lorry { docker run --rm -i --network=cratedb-demo ghcr.io/daq-tools/lorrystream lorry @args } | ||
| function amqpcat { docker run --rm -i --network=cratedb-demo docker.io/cloudamqp/amqpcat amqpcat @args } | ||
| ``` | ||
| ::: | ||
| :::{tab-item} Windows Command | ||
| ```shell | ||
| doskey crash=docker run --rm -it --network=cratedb-demo ghcr.io/crate/cratedb-toolkit crash $* | ||
| doskey lorry=docker run --rm -i --network=cratedb-demo ghcr.io/daq-tools/lorrystream lorry $* | ||
| doskey amqpcat=docker run --rm -i --network=cratedb-demo docker.io/cloudamqp/amqpcat amqpcat $* | ||
| ``` | ||
| ::: | ||
|
|
||
| :::: | ||
|
|
||
| ## Usage | ||
|
|
||
| Invoke the data transfer pipeline. | ||
| ```shell | ||
| lorry relay \ | ||
| "amqp://guest:guest@rabbitmq:5672/%2F?exchange=default&queue=default&routing-key=testdrive&setup=exchange,queue,bind&content-type=json" \ | ||
| "crate://cratedb/?table=testdrive" | ||
| ``` | ||
|
|
||
| Publish a JSON message to AMQP. | ||
| ```shell | ||
| echo '{"temperature": 42.84, "humidity": 83.1}' | \ | ||
| amqpcat --producer --uri='amqp://guest:guest@rabbitmq:5672/%2F' \ | ||
| --exchange=default --queue=default --routing-key=testdrive | ||
| ``` | ||
|
|
||
| Inspect data stored in CrateDB. | ||
| ```shell | ||
| crash --hosts cratedb -c "SELECT * FROM testdrive" | ||
| ``` | ||
|
|
||
|
|
||
| [LorryStream AMQP source]: https://lorrystream.readthedocs.io/source/amqp.html | ||
| [RabbitMQ]: https://www.rabbitmq.com/ | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Broaden AMQP linkcheck ignore to cover non-www, subpaths, and no-trailing-slash variants
The current regex only ignores exactly
https://www.amqp.org/. Links likehttps://amqp.org,https://www.amqp.org(no slash), or any subpage (e.g.,https://www.amqp.org/specs/...) will still be checked and may fail with the same connection issue.Update the pattern to cover both host variants and arbitrary paths.
Apply this diff:
Optional verification script to confirm which AMQP links exist in the docs and ensure they’ll be ignored by the new pattern:
🏁 Script executed:
Length of output: 424
Broaden AMQP linkcheck ignore to cover non-www, subpaths, and no-trailing-slash variants
The repo has AMQP links; the current ignore only matches the exact https://www.amqp.org/ and should be broadened.
Files to note:
Apply this diff:
Verification: ran the suggested grep — occurrences found at docs/conf.py:65 and docs/integrate/amqp/index.md:53; no other variants were present.
📝 Committable suggestion
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai: Apparently it's okay. Please do not over-engineer such nitpicks in this case. In general, we are happy about your diligence, so please just understand it is sometimes not applicable, specifically in a repository which is mostly about documentation instead of serious production code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amotl Thank you for that valuable feedback! I completely understand and appreciate the guidance. You're absolutely right that a simple
r"https://www.amqp.org/"pattern is perfectly adequate for this documentation context, especially when it's already working as intended.I'll keep in mind that documentation repositories often benefit from straightforward, practical solutions rather than comprehensive edge-case handling. Your point about balancing diligence with context-appropriate analysis is well taken - not every scenario requires production-level robustness.
Thanks for the constructive feedback while still acknowledging the intent behind the thoroughness. This helps me better calibrate my suggestions to match the repository's actual needs.
o_(")(") learned something new
✏️ Learnings added