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
28354233
Commit
28354233
authored
Jul 31, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working RabbitMQ as message broker
parent
8d0455c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
deployment.yml
message-broker/deployment/deployment.yml
+1
-1
consumer.py
message-broker/rabbit-mq-test/consumer.py
+21
-0
producer.py
message-broker/rabbit-mq-test/producer.py
+15
-0
No files found.
message-broker/deployment/deployment.yml
View file @
28354233
...
...
@@ -5,7 +5,7 @@ metadata:
name
:
rabbit-mq
spec
:
replicas
:
2
replicas
:
1
selector
:
matchLabels
:
app
:
rabbit-mq
...
...
message-broker/rabbit-mq-test/consumer.py
0 → 100644
View file @
28354233
import
pika
EXCHANGE_NAME
=
'beacon'
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
'143.205.173.36'
,
30302
,
heartbeat
=
600
,
blocked_connection_timeout
=
300
))
channel
=
connection
.
channel
()
channel
.
exchange_declare
(
exchange
=
EXCHANGE_NAME
,
exchange_type
=
'fanout'
)
result
=
channel
.
queue_declare
(
queue
=
''
,
exclusive
=
True
)
queue_name
=
result
.
method
.
queue
channel
.
queue_bind
(
exchange
=
EXCHANGE_NAME
,
queue
=
queue_name
,
routing_key
=
''
)
def
callback
(
ch
,
method
,
properties
,
body
):
print
(
f
"### Received: {body}"
)
ch
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
channel
.
basic_consume
(
queue
=
queue_name
,
auto_ack
=
False
,
on_message_callback
=
callback
)
channel
.
start_consuming
()
message-broker/rabbit-mq-test/producer.py
0 → 100644
View file @
28354233
import
pika
import
random
EXCHANGE_NAME
=
'beacon'
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
'143.205.173.36'
,
30302
,
heartbeat
=
600
,
blocked_connection_timeout
=
300
))
channel
=
connection
.
channel
()
channel
.
exchange_declare
(
exchange
=
EXCHANGE_NAME
,
exchange_type
=
'fanout'
)
message
=
f
'test {random.random()}'
channel
.
basic_publish
(
exchange
=
EXCHANGE_NAME
,
routing_key
=
''
,
body
=
message
)
print
(
f
"# Sent {message}"
)
connection
.
close
()
\ No newline at end of file
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