Skip to content

Commit 5d996b5

Browse files
authored
Claim ActiveMQ Classic support (#91)
1 parent 1ce88c8 commit 5d996b5

File tree

5 files changed

+32
-29
lines changed

5 files changed

+32
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ stompman takes care of cleaning up resources automatically. When you leave the c
127127
Also, I want to pointed out that:
128128

129129
- Protocol parsing is inspired by [aiostomp](https://github.com/pedrokiefer/aiostomp/blob/3449dcb53f43e5956ccc7662bb5b7d76bc6ef36b/aiostomp/protocol.py) (meaning: consumed by me and refactored from).
130-
- stompman is tested and used with [Artemis ActiveMQ](https://activemq.apache.org/components/artemis/).
130+
- stompman is tested and used with [ActiveMQ Artemis](https://activemq.apache.org/components/artemis/) and [ActiveMQ Classic](https://activemq.apache.org/components/classic/).
131131
- 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).
132132

133133
### Examples

docker-compose.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ services:
55
args:
66
PYTHON_IMAGE: ${PYTHON_IMAGE:-python:3.13-slim-bullseye}
77
depends_on:
8-
artemis:
8+
activemq-artemis:
9+
condition: service_started
10+
activemq-classic:
911
condition: service_started
10-
environment:
11-
ARTEMIS_HOST: artemis
1212

13-
artemis:
13+
activemq-artemis:
1414
image: apache/activemq-artemis:2.37.0-alpine
1515
environment:
1616
ARTEMIS_USER: admin
1717
ARTEMIS_PASSWORD: ":=123"
1818
ports:
1919
- 8161:8161
2020
- 61616:61616
21+
22+
activemq-classic:
23+
image: apache/activemq-classic:6.1.2
24+
environment:
25+
ACTIVEMQ_CONNECTION_USER: admin
26+
ACTIVEMQ_CONNECTION_PASSWORD: ":=123"

examples/consumer.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import asyncio
2-
import os
32

43
import stompman
54

6-
server = stompman.ConnectionParameters(
7-
host=os.environ.get("ARTEMIS_HOST", "0.0.0.0"), # noqa: S104
8-
port=61616,
9-
login="admin",
10-
passcode=":=123",
11-
)
5+
server = stompman.ConnectionParameters(host="0.0.0.0", port=61616, login="admin", passcode=":=123") # noqa: S104
126

137

148
async def handle_message(message_frame: stompman.MessageFrame) -> None:

examples/producer.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import asyncio
2-
import os
32

43
import stompman
54

6-
server = stompman.ConnectionParameters(
7-
host=os.environ.get("ARTEMIS_HOST", "0.0.0.0"), # noqa: S104
8-
port=61616,
9-
login="admin",
10-
passcode=":=123",
11-
)
5+
server = stompman.ConnectionParameters(host="0.0.0.0", port=61616, login="admin", passcode=":=123") # noqa: S104
126

137

148
async def main() -> None:

tests/integration.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import asyncio
2-
import os
32
from collections.abc import AsyncGenerator, Callable
43
from contextlib import asynccontextmanager
54
from itertools import starmap
6-
from typing import Final
5+
from typing import Final, cast
76
from uuid import uuid4
87

98
import pytest
@@ -21,23 +20,29 @@
2120
parse_header,
2221
)
2322

24-
pytestmark = pytest.mark.anyio
23+
DESTINATION: Final = "DLQ"
24+
2525

26-
CONNECTION_PARAMETERS: Final = stompman.ConnectionParameters(
27-
host=os.environ["ARTEMIS_HOST"], port=61616, login="admin", passcode=":=123"
26+
@pytest.fixture(
27+
params=[
28+
stompman.ConnectionParameters(host="activemq-artemis", port=61616, login="admin", passcode=":=123"),
29+
stompman.ConnectionParameters(host="activemq-classic", port=61613, login="admin", passcode=":=123"),
30+
]
2831
)
29-
DESTINATION: Final = "DLQ"
32+
def connection_parameters(request: pytest.FixtureRequest) -> stompman.ConnectionParameters:
33+
return cast(stompman.ConnectionParameters, request.param)
3034

3135

3236
@asynccontextmanager
33-
async def create_client() -> AsyncGenerator[stompman.Client, None]:
37+
async def create_client(connection_parameters: stompman.ConnectionParameters) -> AsyncGenerator[stompman.Client, None]:
3438
async with stompman.Client(
35-
servers=[CONNECTION_PARAMETERS], read_timeout=10, connection_confirmation_timeout=10
39+
servers=[connection_parameters], read_timeout=10, connection_confirmation_timeout=10
3640
) as client:
3741
yield client
3842

3943

40-
async def test_ok() -> None:
44+
@pytest.mark.anyio
45+
async def test_ok(connection_parameters: stompman.ConnectionParameters) -> None:
4146
async def produce() -> None:
4247
for message in messages[200:]:
4348
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
6570

6671
messages = [str(uuid4()).encode() for _ in range(10000)]
6772

68-
async with create_client() as consumer, create_client() as producer, asyncio.TaskGroup() as task_group:
73+
async with (
74+
create_client(connection_parameters) as consumer,
75+
create_client(connection_parameters) as producer,
76+
asyncio.TaskGroup() as task_group,
77+
):
6978
task_group.create_task(consume())
7079
task_group.create_task(produce())
7180

0 commit comments

Comments
 (0)