Repository: vrslev/stompman (language: python)

Issue:
test with Classic ActiveMQ
Hi,

This seems like the best asyncio implementation of STOMP. Thanks!!.
The readme says it was tested with Artemis ActiveMQ. I was wondering if there is any experience with Classic ActiveMQ testing as we probably need to use that one.

Thanks!!


Discussion / hints:
Hi! Thanks for your kind words ☺️

Does Classic ActiveMQ has a Docker image I can use in integration tests?
Hi,

Yes, please see at:
https://hub.docker.com/r/apache/activemq-classic/tags

Thanks!!
Ok, I'll look into it later, thanks!

Fix patch:
diff --git a/README.md b/README.md
index 911cf9d..590873d 100644
--- a/README.md
+++ b/README.md
@@ -127,7 +127,7 @@ stompman takes care of cleaning up resources automatically. When you leave the c
 Also, I want to pointed out that:
 
 - Protocol parsing is inspired by [aiostomp](https://github.com/pedrokiefer/aiostomp/blob/3449dcb53f43e5956ccc7662bb5b7d76bc6ef36b/aiostomp/protocol.py) (meaning: consumed by me and refactored from).
-- stompman is tested and used with [Artemis ActiveMQ](https://activemq.apache.org/components/artemis/).
+- stompman is tested and used with [ActiveMQ Artemis](https://activemq.apache.org/components/artemis/) and [ActiveMQ Classic](https://activemq.apache.org/components/classic/).
 - Specification says that headers in CONNECT and CONNECTED frames shouldn't be escaped for backwards compatibility. stompman escapes headers in CONNECT frame (outcoming), but does not unescape headers in CONNECTED (outcoming).
 
 ### Examples
diff --git a/docker-compose.yml b/docker-compose.yml
index 45a8222..b64fd93 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,12 +5,12 @@ services:
       args:
         PYTHON_IMAGE: ${PYTHON_IMAGE:-python:3.13-slim-bullseye}
     depends_on:
-      artemis:
+      activemq-artemis:
+        condition: service_started
+      activemq-classic:
         condition: service_started
-    environment:
-      ARTEMIS_HOST: artemis
 
-  artemis:
+  activemq-artemis:
     image: apache/activemq-artemis:2.37.0-alpine
     environment:
       ARTEMIS_USER: admin
@@ -18,3 +18,9 @@ services:
     ports:
       - 8161:8161
       - 61616:61616
+
+  activemq-classic:
+    image: apache/activemq-classic:6.1.2
+    environment:
+      ACTIVEMQ_CONNECTION_USER: admin
+      ACTIVEMQ_CONNECTION_PASSWORD: ":=123"
diff --git a/examples/consumer.py b/examples/consumer.py
index 3eaba08..5bde055 100644
--- a/examples/consumer.py
+++ b/examples/consumer.py
@@ -1,14 +1,8 @@
 import asyncio
-import os
 
 import stompman
 
-server = stompman.ConnectionParameters(
-    host=os.environ.get("ARTEMIS_HOST", "0.0.0.0"),  # noqa: S104
-    port=61616,
-    login="admin",
-    passcode=":=123",
-)
+server = stompman.ConnectionParameters(host="0.0.0.0", port=61616, login="admin", passcode=":=123")  # noqa: S104
 
 
 async def handle_message(message_frame: stompman.MessageFrame) -> None:
diff --git a/examples/producer.py b/examples/producer.py
index 8fd1533..05eb1f8 100644
--- a/examples/producer.py
+++ b/examples/producer.py
@@ -1,14 +1,8 @@
 import asyncio
-import os
 
 import stompman
 
-server = stompman.ConnectionParameters(
-    host=os.environ.get("ARTEMIS_HOST", "0.0.0.0"),  # noqa: S104
-    port=61616,
-    login="admin",
-    passcode=":=123",
-)
+server = stompman.ConnectionParameters(host="0.0.0.0", port=61616, login="admin", passcode=":=123")  # noqa: S104
 
 
 async def main() -> None:


Test patch:
diff --git a/tests/integration.py b/tests/integration.py
index 0609262..670b8a6 100644
--- a/tests/integration.py
+++ b/tests/integration.py
@@ -1,9 +1,8 @@
 import asyncio
-import os
 from collections.abc import AsyncGenerator, Callable
 from contextlib import asynccontextmanager
 from itertools import starmap
-from typing import Final
+from typing import Final, cast
 from uuid import uuid4
 
 import pytest
@@ -21,23 +20,29 @@
     parse_header,
 )
 
-pytestmark = pytest.mark.anyio
+DESTINATION: Final = "DLQ"
+
 
-CONNECTION_PARAMETERS: Final = stompman.ConnectionParameters(
-    host=os.environ["ARTEMIS_HOST"], port=61616, login="admin", passcode=":=123"
+@pytest.fixture(
+    params=[
+        stompman.ConnectionParameters(host="activemq-artemis", port=61616, login="admin", passcode=":=123"),
+        stompman.ConnectionParameters(host="activemq-classic", port=61613, login="admin", passcode=":=123"),
+    ]
 )
-DESTINATION: Final = "DLQ"
+def connection_parameters(request: pytest.FixtureRequest) -> stompman.ConnectionParameters:
+    return cast(stompman.ConnectionParameters, request.param)
 
 
 @asynccontextmanager
-async def create_client() -> AsyncGenerator[stompman.Client, None]:
+async def create_client(connection_parameters: stompman.ConnectionParameters) -> AsyncGenerator[stompman.Client, None]:
     async with stompman.Client(
-        servers=[CONNECTION_PARAMETERS], read_timeout=10, connection_confirmation_timeout=10
+        servers=[connection_parameters], read_timeout=10, connection_confirmation_timeout=10
     ) as client:
         yield client
 
 
-async def test_ok() -> None:
+@pytest.mark.anyio
+async def test_ok(connection_parameters: stompman.ConnectionParameters) -> None:
     async def produce() -> None:
         for message in messages[200:]:
             await producer.send(body=message, destination=DESTINATION, headers={"hello": "from outside transaction"})
@@ -65,7 +70,11 @@ async def handle_message(frame: stompman.MessageFrame) -> None:  # noqa: RUF029
 
     messages = [str(uuid4()).encode() for _ in range(10000)]
 
-    async with create_client() as consumer, create_client() as producer, asyncio.TaskGroup() as task_group:
+    async with (
+        create_client(connection_parameters) as consumer,
+        create_client(connection_parameters) as producer,
+        asyncio.TaskGroup() as task_group,
+    ):
         task_group.create_task(consume())
         task_group.create_task(produce())