Skip to content

Commit 061a42f

Browse files
author
DanielePalaia
committed
some improvements
1 parent 6c86328 commit 061a42f

File tree

8 files changed

+17
-38
lines changed

8 files changed

+17
-38
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
This library is in early stages of development. It is meant to be used with RabbitMQ 4.0.
44

5-
## How to Run
5+
## How to Build the project and run the tests
6+
7+
- Start a RabbitMQ 4.x broker
8+
- poetry build: build the source project
9+
- poetry install: resolves and install dependencies
10+
- poetry run pytest: run the tests
611

712
## Getting Started
813

14+
An example is provide in ./getting_started_main.py you can run it after starting a RabbitMQ 4.0 broker with:
15+
16+
poetry run python ./examples/getting_started/main.py
17+
918

examples/getting_started/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def main() -> None:
4848
print("unbind")
4949
management.unbind(bind_name)
5050

51-
print("purging queue")
51+
print("purging the queue")
5252
management.purge_queue(queue_name)
5353

5454
print("delete queue")

rabbitmq_amqp_python_client/connection.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@ def management(self) -> Management:
2828

2929
# closes the connection to the AMQP 1.0 server.
3030
def close(self) -> None:
31+
logger.debug("Closing connection")
3132
self._conn.close()
3233

3334
def publisher(self, destination: str) -> Publisher:
3435
publisher = Publisher(self._conn, destination)
3536
return publisher
36-
37-
# TODO: returns the current status of the connection.
38-
# def status(self) -> int:
39-
# pass

rabbitmq_amqp_python_client/entities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ class QueueSpecification:
3131
class BindingSpecification:
3232
source_exchange: str
3333
destination_queue: str
34-
# destination_exchange: str
3534
binding_key: str

rabbitmq_amqp_python_client/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ class ValidationCodeException(Exception):
33
def __init__(self, msg: str):
44
self.msg = msg
55

6-
# __str__ is to print() the value
76
def __str__(self) -> str:
87
return repr(self.msg)

rabbitmq_amqp_python_client/management.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def _validate_reponse_code(
191191
"wrong response code received: " + str(response_code)
192192
)
193193

194-
# TODO
195194
def bind(self, bind_specification: BindingSpecification) -> str:
196195
logger.debug("Bind Operation called")
197196
body = {}
@@ -214,7 +213,6 @@ def bind(self, bind_specification: BindingSpecification) -> str:
214213
binding_path_with_queue = binding_path_with_exchange_queue(bind_specification)
215214
return binding_path_with_queue
216215

217-
# TODO
218216
def unbind(self, binding_exchange_queue_path: str) -> None:
219217
logger.debug("UnBind Operation called")
220218
self.request(
@@ -226,16 +224,10 @@ def unbind(self, binding_exchange_queue_path: str) -> None:
226224
],
227225
)
228226

229-
# TODO
230-
# def queue_info(self, queue_name:str):
231-
232-
# TODO
233227
def purge_queue(self, queue_name: str) -> None:
234228
logger.debug("purge_queue operation called")
235229
path = purge_queue_address(queue_name)
236230

237-
print("path: " + path)
238-
239231
self.request(
240232
None,
241233
path,

rabbitmq_amqp_python_client/publisher.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ def publish(self, message: Message) -> None:
3030
self._sender.send(message)
3131

3232
def close(self) -> None:
33+
logger.debug("Closing Sender and Receiver")
3334
if self._sender is not None:
3435
self._sender.close()
35-
# if self._receiver is not None:
36-
# self._receiver.close()
36+
if self._receiver is not None:
37+
self._receiver.close()
3738

3839
def _create_sender(self, addr: str) -> BlockingSender:
3940
return self._conn.create_sender(addr, options=SenderOption(addr))

rabbitmq_amqp_python_client/qpid/proton/_message.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ def encode_delete(self) -> bytes:
556556
continue
557557
else:
558558
self._check(err)
559+
# workaround because of: https://github.com/rabbitmq/rabbitmq-amqp-python-client/issues/1
559560
if self.body is None:
560561
data[0] = 0
561562
data[1] = 83
@@ -580,6 +581,7 @@ def send(self, sender: "Sender", tag: Optional[str] = None) -> "Delivery":
580581
"""
581582
dlv = sender.delivery(tag or sender.delivery_tag())
582583

584+
# workaround because of: https://github.com/rabbitmq/rabbitmq-amqp-python-client/issues/1
583585
if sender.target.address == "/management":
584586
encoded = self.encode_delete()
585587
else:
@@ -591,26 +593,6 @@ def send(self, sender: "Sender", tag: Optional[str] = None) -> "Delivery":
591593
dlv.settle()
592594
return dlv
593595

594-
def send_mngmnt(self, sender: "Sender", tag: Optional[str] = None) -> "Delivery":
595-
"""
596-
Encodes and sends the message content using the specified sender,
597-
and, if present, using the specified tag. Upon success, will
598-
return the :class:`Delivery` object for the sent message.
599-
600-
:param sender: The sender to send the message
601-
:param tag: The delivery tag for the sent message
602-
:return: The delivery associated with the sent message
603-
"""
604-
dlv = sender.delivery(tag or sender.delivery_tag())
605-
606-
encoded = self.encode_delete()
607-
608-
sender.stream(encoded)
609-
sender.advance()
610-
if sender.snd_settle_mode == Link.SND_SETTLED:
611-
dlv.settle()
612-
return dlv
613-
614596
@overload
615597
def recv(self, link: "Sender") -> None: ...
616598

0 commit comments

Comments
 (0)