Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
data_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
11d9dcb4
authored
Aug 29, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add pika version
parent
325a8d95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
server.py
server.py
View file @
11d9dcb4
...
...
@@ -25,9 +25,11 @@ def listen_from_mq():
credentials
=
credentials
))
channel
=
conn
.
channel
()
channel
.
queue_declare
(
queue
=
config
.
rabbit_mq_queue_consumer
,
durable
=
True
)
# 注意 py3.8 的api 和 python3.6的api 是有区别的
# channel.basic_consume(callback, queue=config.rabbit_mq_queue_consumer)
channel
.
basic_consume
(
queue
=
config
.
rabbit_mq_queue_consumer
,
on_message_callback
=
callback
)
"""测试环境和生产环境的pika版本不同"""
if
pika
.
__version__
[
0
]
==
"1"
:
channel
.
basic_consume
(
queue
=
config
.
rabbit_mq_queue_consumer
,
on_message_callback
=
callback
)
else
:
channel
.
basic_consume
(
callback
,
queue
=
config
.
rabbit_mq_queue_consumer
)
channel
.
start_consuming
()
...
...
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