Skip to content
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

bug: pass Conn.connection_parameters to pika.BlockingConnection #80

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions python/idsse_common/idsse/common/rabbitmq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ def _initialize_connection_and_channel(
# connection of unsupported type passed
raise ValueError(
(f'Cannot use or create new RabbitMQ connection using type {type(connection)}. '
'Should a Conn (a dict with connection parameters)')
'Should be type Conn (a dict with connection parameters)')
)

_connection = BlockingConnection(parameters=connection)
_connection = BlockingConnection(connection.connection_parameters)
logger.info('Established new RabbitMQ connection to %s on port %i',
connection.host, connection.port)

Expand Down Expand Up @@ -352,7 +352,7 @@ class Consumer(Thread):
"""
def __init__(
self,
conn_params: ConnectionParameters,
conn_params: Conn,
rmq_params_and_callbacks: RabbitMqParamsAndCallback | list[RabbitMqParamsAndCallback],
num_message_handlers: int,
*args,
Expand All @@ -366,7 +366,7 @@ def __init__(
self._rmq_params_and_callbacks = rmq_params_and_callbacks
else:
self._rmq_params_and_callbacks = [rmq_params_and_callbacks]
self.connection = BlockingConnection(parameters=self._conn_params)
self.connection = BlockingConnection(self._conn_params.connection_parameters)
self.channel = self.connection.channel()

self._consumer_tags = []
Expand Down Expand Up @@ -420,7 +420,7 @@ class Publisher(Thread):
"""
def __init__(
self,
conn_params: ConnectionParameters,
conn_params: Conn,
exch_params: Exch,
*args,
**kwargs,
Expand All @@ -431,7 +431,7 @@ def __init__(
self._exch = exch_params
self._queue = None

self.connection = BlockingConnection(conn_params)
self.connection = BlockingConnection(conn_params.connection_parameters)
self.channel = self.connection.channel()

# if delivery is mandatory there must be a queue attach to the exchange
Expand Down Expand Up @@ -506,6 +506,7 @@ def stop(self):
self.channel.close,
self.connection.close)

# pylint: disable=too-many-arguments,unused-argument
def _publish(
self,
message: bytes,
Expand Down Expand Up @@ -535,7 +536,6 @@ def _publish(
mandatory=self._exch.mandatory)
if success_flag:
success_flag[0] = True
print('\n message published\n')
if self._queue and self._queue.name.startswith('_'):
try:
self.channel.queue_purge(queue=self._queue.name)
Expand Down
Loading