Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
7b6acafd
Commit
7b6acafd
authored
Sep 16, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MessageManager initialization is async
parent
939c61bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
MessageManager.py
modules/messaging/MessageManager.py
+8
-4
ReconnectingMessageManager.py
modules/messaging/ReconnectingMessageManager.py
+6
-2
No files found.
modules/messaging/MessageManager.py
View file @
7b6acafd
...
@@ -55,11 +55,12 @@ class MessageManager:
...
@@ -55,11 +55,12 @@ class MessageManager:
self
.
_receive_channel
=
channel
self
.
_receive_channel
=
channel
LOGGER
.
info
(
"RabbitMQ connection established"
)
LOGGER
.
info
(
"RabbitMQ connection established"
)
def
create_exchange_with_queue
(
self
,
exchange_name
,
exchange_type
,
queue_name
):
def
create_exchange_with_queue
(
self
,
exchange_name
,
exchange_type
,
queue_name
,
callback
):
'''Creates exchange and queue and binds them'''
'''Creates exchange and queue and binds them'''
self
.
_prepare_receive_parameters
=
{
'exchange_name'
:
exchange_name
,
self
.
_prepare_receive_parameters
=
{
'exchange_name'
:
exchange_name
,
'exchange_type'
:
exchange_type
,
'exchange_type'
:
exchange_type
,
'queue_name'
:
queue_name
}
'queue_name'
:
queue_name
,
'callback'
:
callback
}
self
.
_receive_channel
.
exchange_declare
(
exchange
=
exchange_name
,
exchange_type
=
exchange_type
,
callback
=
self
.
_exchange_created_callback
)
self
.
_receive_channel
.
exchange_declare
(
exchange
=
exchange_name
,
exchange_type
=
exchange_type
,
callback
=
self
.
_exchange_created_callback
)
...
@@ -74,8 +75,11 @@ class MessageManager:
...
@@ -74,8 +75,11 @@ class MessageManager:
exchange_name
=
self
.
_prepare_receive_parameters
[
'exchange_name'
]
exchange_name
=
self
.
_prepare_receive_parameters
[
'exchange_name'
]
# Bind queue to exchange
# Bind queue to exchange
self
.
_receive_channel
.
queue_bind
(
exchange
=
exchange_name
,
queue
=
queue_name
)
self
.
_receive_channel
.
queue_bind
(
exchange
=
exchange_name
,
queue
=
queue_name
,
callback
=
self
.
_queue_bound_callback
)
LOGGER
.
info
(
f
"RabbitMQ connection to exchange '{exchange_name}' established"
)
def
_queue_bound_callback
(
self
,
_
):
if
self
.
_prepare_receive_parameters
[
'callback'
]
!=
None
:
self
.
_prepare_receive_parameters
[
'callback'
]()
def
start_consuming
(
self
,
queue_name
,
auto_ack
,
message_received_callback
):
def
start_consuming
(
self
,
queue_name
,
auto_ack
,
message_received_callback
):
'''Starts listening for messages'''
'''Starts listening for messages'''
...
...
modules/messaging/ReconnectingMessageManager.py
View file @
7b6acafd
...
@@ -53,8 +53,12 @@ class ReconnectingMessageManager:
...
@@ -53,8 +53,12 @@ class ReconnectingMessageManager:
'message_received_callback'
:
message_received_callback
}
'message_received_callback'
:
message_received_callback
}
self
.
_consuming
=
True
self
.
_consuming
=
True
self
.
_message_manager
.
create_exchange_with_queue
(
exchange_name
,
exchange_type
,
queue_name
)
self
.
_message_manager
.
create_exchange_with_queue
(
exchange_name
,
exchange_type
,
queue_name
,
self
.
_exchange_created_callback
)
self
.
_message_manager
.
start_consuming
(
queue_name
,
auto_ack
,
message_received_callback
)
def
_exchange_created_callback
(
self
):
self
.
_message_manager
.
start_consuming
(
self
.
_consumption_parameters
[
'queue_name'
],
self
.
_consumption_parameters
[
'auto_ack'
],
self
.
_consumption_parameters
[
'message_received_callback'
])
def
create_message_destination
(
self
,
exchange_name
,
exchange_type
):
def
create_message_destination
(
self
,
exchange_name
,
exchange_type
):
'''Creates the exchange'''
'''Creates the exchange'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment