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
1c2807f5
Commit
1c2807f5
authored
Jul 05, 2021
by
AVPetukhov
Browse files
Delete consumer.py
parent
00523b89
Changes
1
Show whitespace changes
Inline
Side-by-side
consumer.py
deleted
100644 → 0
View file @
00523b89
#!/usr/bin/env python
import
pika
,
time
,
sys
# имя файла, который будем забирать для обработки в 1С
fileName
=
"d:/from_rabbit.xml"
credentials
=
pika
.
PlainCredentials
(
'user_name'
,
'password'
)
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
'host_name'
,
5672
,
'/'
,
credentials
))
channel
=
connection
.
channel
()
# забираем из очереди
channel
.
queue_declare
(
queue
=
'consume_queue'
,
durable
=
True
)
def
callback
(
ch
,
method
,
properties
,
body
):
file
=
open
(
fileName
,
"w"
,
encoding
=
"utf-8"
)
file
.
write
(
body
.
decode
(
"utf-8"
))
file
.
close
()
# время ожидания чтобы на стороне 1С успел обработаться файл
time
.
sleep
(
body
.
count
(
b
'.'
)
/
100
)
ch
.
basic_ack
(
delivery_tag
=
method
.
delivery_tag
)
channel
.
basic_qos
(
prefetch_count
=
1
)
channel
.
basic_consume
(
callback
,
queue
=
'consume_queue'
)
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