Repository navigation
feat(amgi-stomp): add STOMP support #122
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
Open
TomKimber
wants to merge
1
commit into
main
Choose a base branch
from
feat/add-stomp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| 3.10 | ||
| 3.11 | ||
| 3.12 | ||
| 3.13 | ||
| 3.14 | ||
| 3.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| services: | ||
| activemq-artemis: | ||
| image: ghcr.io/asyncfast/apache/activemq-artemis:2.44.0 | ||
| restart: unless-stopped | ||
| ports: | ||
| - "61613:61613" | ||
| - "8161:8161" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 Jack Burridge | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # amgi-stomp | ||
|
|
||
| amgi-stomp is an [AMGI](https://amgi.readthedocs.io/en/latest/) compatible server to run AMGI applications against | ||
| [STOMP](https://stomp.github.io/) brokers using [stompman](https://pypi.org/project/stompman/). | ||
|
|
||
| amgi-stomp requires Python 3.11 or greater, as this is the minimum version supported by `stompman`. | ||
|
|
||
| ## Installation | ||
|
|
||
| ``` | ||
| pip install amgi-stomp==0.47.0 | ||
| ``` | ||
|
|
||
| ## Example | ||
|
|
||
| This example uses [AsyncFast](https://pypi.org/project/asyncfast/): | ||
|
|
||
| ```python | ||
| from dataclasses import dataclass | ||
|
|
||
| from amgi_stomp import run | ||
| from asyncfast import AsyncFast | ||
|
|
||
| app = AsyncFast() | ||
|
|
||
|
|
||
| @dataclass | ||
| class Order: | ||
| item_ids: list[str] | ||
|
|
||
|
|
||
| @app.channel("order-queue") | ||
| async def order_queue(order: Order) -> None: | ||
| # Makes an order | ||
| ... | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run(app, "order-queue") | ||
| ``` | ||
|
|
||
| Or the application could be run via the commandline: | ||
|
|
||
| ```commandline | ||
| asyncfast run amgi-stomp main:app order-queue | ||
| ``` | ||
|
|
||
| Messages are consumed with `client-individual` acknowledgement mode. Sending `message.ack` or `message.nack` events | ||
| acknowledges or rejects the current STOMP message. Whether messages that are never acknowledged or are nacked are | ||
| redelivered, dead-lettered, or discarded depends on the broker's configuration. | ||
|
|
||
| If an application raises an exception while handling a message, the exception is logged and the message is nacked; what the | ||
| broker does with a nacked message (redeliver, dead-letter, or discard) is broker-specific. | ||
|
|
||
| The STOMP protocol metadata of a received message is available in the AMGI message scope: | ||
| `message["bindings"]["stomp"]["message_id"]` and `message["bindings"]["stomp"]["subscription"]`. When using AsyncFast, | ||
| these can be received directly with the `asyncfast.StompMessageId` and `asyncfast.StompSubscription` bindings. | ||
|
|
||
| By default, messages are sent without waiting for a broker receipt. Pass a `receipt_timeout` in seconds to `run`, | ||
| `Server`, or `MessageSend` to wait for a receipt confirming the broker processed the SEND frame, at the cost of a broker round-trip. A receipt does | ||
| not by itself make a message durable; persistence is broker-specific. Pass | ||
| `ssl=True` or an `ssl.SSLContext` via the `ssl` parameter of `run` or `Server` to connect over TLS. The `heartbeat`, | ||
| `connect_retry_attempts`, and `connect_retry_interval` parameters expose stompman's heartbeat and connection retry | ||
| options without changing its defaults. | ||
|
|
||
| ## Contact | ||
|
|
||
| For questions or suggestions, please contact [jack.burridge@mail.com](mailto:jack.burridge@mail.com). | ||
|
|
||
| ## License | ||
|
|
||
| Copyright 2025 AMGI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| [build-system] | ||
| build-backend = "uv_build" | ||
| requires = [ | ||
| "uv-build>=0.8.14,<0.9.0", | ||
| ] | ||
|
|
||
| [project] | ||
| name = "amgi-stomp" | ||
| version = "0.49.0" | ||
| description = "AMGI STOMP Server" | ||
| readme = "README.md" | ||
| license = "MIT" | ||
| license-files = [ | ||
| "LICENSE", | ||
| ] | ||
| authors = [ | ||
| { name = "jack.burridge", email = "jack.burridge@mail.com" }, | ||
| ] | ||
| requires-python = ">=3.10" | ||
| classifiers = [ | ||
| "Programming Language :: Python :: 3 :: Only", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Programming Language :: Python :: 3.14", | ||
| ] | ||
| dependencies = [ | ||
| "amgi-common==0.49.0", | ||
| "amgi-types==0.49.0", | ||
| "stompman>=3.16.0; python_full_version>='3.11'", | ||
| ] | ||
| entry-points.amgi_server.amgi-stomp = "amgi_stomp:_run_cli" | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "pytest>=8.4.1", | ||
| "pytest-asyncio>=1.3.0", | ||
| "pytest-cov>=7.0.0", | ||
| "pytest-timeout>=2.4.0", | ||
| "test-utils", | ||
| "testcontainers>=4.13.0", | ||
| ] | ||
|
|
||
| [tool.uv] | ||
| sources.amgi-common.workspace = true | ||
| sources.amgi-types.workspace = true | ||
| sources.test-utils.workspace = true | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.