Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
communications-backbone
Commits
2b132a1b
Commit
2b132a1b
authored
2 years ago
by
James Kirk
Browse files
Options
Download
Email Patches
Plain Diff
refactor: minor tidying up, linking issue, and improving err
parent
0638b941
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
rmq.py
rmq.py
+4
-4
No files found.
rmq.py
View file @
2b132a1b
...
...
@@ -2,7 +2,7 @@ import json
import
pika
host
=
'localhost'
# TODO Handle host being passed in
host
=
'localhost'
# TODO Handle host being passed in
(https://git.noc.ac.uk/communications-backbone-system/communications-backbone/-/issues/17)
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
...
...
@@ -36,7 +36,7 @@ def deliver_to_exchange(channel, body, exchange_name, topic=None):
)
)
else
:
topic_exchange
(
channel
=
channel
,
exchange_name
=
exchange_name
,
topic
=
topic
)
topic_exchange
(
channel
=
channel
,
exchange_name
=
exchange_name
)
channel
.
basic_publish
(
exchange
=
exchange_name
,
routing_key
=
topic
,
...
...
@@ -79,7 +79,7 @@ def read_from_queue(queue_name, max_msgs):
channel
.
basic_ack
(
method_frame
.
delivery_tag
)
try
:
messages
.
append
(
json
.
loads
(
body
.
decode
()))
except
:
except
json
.
decoder
.
JSONDecodeError
:
messages
.
append
(
body
.
decode
())
else
:
print
(
"No message returned"
)
...
...
@@ -161,7 +161,7 @@ def subscribe(queue_name, exchange_name, topic=None):
fanout_exchange
(
channel
=
channel
,
exchange_name
=
exchange_name
)
channel
.
queue_bind
(
exchange
=
exchange_name
,
queue
=
queue_name
)
else
:
topic_exchange
(
channel
=
channel
,
exchange_name
=
exchange_name
,
topic
=
topic
)
topic_exchange
(
channel
=
channel
,
exchange_name
=
exchange_name
)
channel
.
queue_bind
(
exchange
=
exchange_name
,
queue
=
queue_name
,
routing_key
=
topic
)
connection
.
close
()
...
...
This diff is collapsed.
Click to expand it.
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