Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
AVPetukhov
Practica 2021
Commits
e319913d
Commit
e319913d
authored
Jul 07, 2021
by
AVPetukhov
Browse files
Upload New File
parent
e1df4f23
Changes
1
Hide whitespace changes
Inline
Side-by-side
consumerV2.py
0 → 100644
View file @
e319913d
import
pika
,
sys
,
os
import
json
import
matplotlib.pyplot
as
plt
y
=
[]
plt
.
grid
()
def
main
():
credentials
=
pika
.
PlainCredentials
(
'Anton'
,
'Anton'
)
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'217.9.89.214'
,
port
=
5672
,
virtual_host
=
'/'
,
credentials
=
credentials
))
channel
=
connection
.
channel
()
channel
.
queue_declare
(
queue
=
'Anton'
)
def
callback
(
ch
,
method
,
properties
,
body
):
data
=
json
.
loads
(
body
)
print
(
data
)
plt
.
plot
(
data
[
0
],
data
[
1
])
plt
.
show
()
channel
.
basic_consume
(
queue
=
'Anton'
,
on_message_callback
=
callback
,
auto_ack
=
True
)
print
(
'Waiting for messages. To exit press CTRL+C'
)
channel
.
start_consuming
()
if
__name__
==
'__main__'
:
try
:
main
()
except
KeyboardInterrupt
:
print
(
'Interrupted'
)
try
:
sys
.
exit
(
0
)
except
SystemExit
:
os
.
_exit
(
0
)
\ 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