Skip to content

Commit 98f5479

Browse files
author
DanielePalaia
committed
when publishing messages we need to setup unseattle option
1 parent 30b5ca1 commit 98f5479

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

examples/getting_started/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def main() -> None:
7070
exchange_name = "test-exchange"
7171
queue_name = "example-queue"
7272
routing_key = "routing-key"
73-
messages_to_publish = 100
73+
messages_to_publish = 100000
7474

7575
print("connection to amqp server")
7676
connection = create_connection()
@@ -112,9 +112,9 @@ def main() -> None:
112112
status = publisher.publish(Message(body="test"))
113113
if status.ACCEPTED:
114114
print("message accepted")
115-
if status.RELEASED:
115+
elif status.RELEASED:
116116
print("message not routed")
117-
if status.REJECTED:
117+
elif status.REJECTED:
118118
print("message not rejected")
119119

120120
publisher.close()

rabbitmq_amqp_python_client/options.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ def test(self, link: Link) -> bool:
2121
return bool(link.is_sender)
2222

2323

24+
class SenderOptionUnseattle(LinkOption): # type: ignore
25+
def __init__(self, addr: str):
26+
self._addr = addr
27+
28+
def apply(self, link: Link) -> None:
29+
link.source.address = self._addr
30+
link.snd_settle_mode = Link.SND_UNSETTLED
31+
link.rcv_settle_mode = Link.RCV_FIRST
32+
link.properties = PropertyDict({symbol("paired"): True})
33+
link.source.dynamic = False
34+
35+
def test(self, link: Link) -> bool:
36+
return bool(link.is_sender)
37+
38+
2439
class ReceiverOption(LinkOption): # type: ignore
2540
def __init__(self, addr: str):
2641
self._addr = addr

rabbitmq_amqp_python_client/publisher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from typing import Optional
33

4-
from .options import SenderOption
4+
from .options import SenderOptionUnseattle
55
from .qpid.proton._delivery import Delivery
66
from .qpid.proton._message import Message
77
from .qpid.proton.utils import (
@@ -34,4 +34,4 @@ def close(self) -> None:
3434
self._sender.close()
3535

3636
def _create_sender(self, addr: str) -> BlockingSender:
37-
return self._conn.create_sender(addr, options=SenderOption(addr))
37+
return self._conn.create_sender(addr, options=SenderOptionUnseattle(addr))

0 commit comments

Comments
 (0)