Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
jd_data_process
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
6338a78e
authored
Nov 06, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add push mq
parent
a5027a7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
push_to_mq.py
push_to_mq.py
View file @
6338a78e
...
@@ -15,7 +15,7 @@ username = 'huntadmin'
...
@@ -15,7 +15,7 @@ username = 'huntadmin'
password
=
'jy2y2900'
password
=
'jy2y2900'
host
=
'172.18.137.29'
host
=
'172.18.137.29'
port
=
5672
port
=
5672
queue_name
=
'liexin_nplm_vc_sku_update'
#
queue_name = 'liexin_nplm_vc_sku_update'
config_prod
=
{
config_prod
=
{
...
@@ -33,7 +33,7 @@ config_prod = {
...
@@ -33,7 +33,7 @@ config_prod = {
}
}
}
}
def
push_mq
(
message
:
str
):
def
push_mq
(
message
:
str
,
queue_name
:
str
,
routing_key
:
str
):
credentials
=
pika
.
PlainCredentials
(
username
=
username
,
password
=
password
)
credentials
=
pika
.
PlainCredentials
(
username
=
username
,
password
=
password
)
conn
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
conn
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
host
,
host
=
host
,
...
@@ -42,7 +42,7 @@ def push_mq(message: str):
...
@@ -42,7 +42,7 @@ def push_mq(message: str):
))
))
channel
=
conn
.
channel
()
channel
=
conn
.
channel
()
channel
.
queue_declare
(
queue
=
queue_name
,
durable
=
True
)
channel
.
queue_declare
(
queue
=
queue_name
,
durable
=
True
)
channel
.
basic_publish
(
exchange
=
""
,
routing_key
=
"liexin_nplm_vc_sku_update"
,
body
=
str
.
encode
(
message
))
channel
.
basic_publish
(
exchange
=
""
,
routing_key
=
routing_key
,
body
=
str
.
encode
(
message
))
channel
.
close
()
channel
.
close
()
conn
.
close
()
conn
.
close
()
...
@@ -66,7 +66,6 @@ def post_msg(conf: dict):
...
@@ -66,7 +66,6 @@ def post_msg(conf: dict):
"shop_id"
:
shop_id
"shop_id"
:
shop_id
}
}
msg_str
=
json
.
dumps
(
data
,
ensure_ascii
=
False
)
msg_str
=
json
.
dumps
(
data
,
ensure_ascii
=
False
)
push_mq
(
msg_str
)
# {"goods_id":1170115972487102103,"spu_id":2170115972437912400,"platform":1,"shop_id":1}
# {"goods_id":1170115972487102103,"spu_id":2170115972437912400,"platform":1,"shop_id":1}
...
@@ -91,7 +90,7 @@ def post_jd_is_null(conf: dict):
...
@@ -91,7 +90,7 @@ def post_jd_is_null(conf: dict):
"shop_id"
:
shop_id
"shop_id"
:
shop_id
}
}
msg_str
=
json
.
dumps
(
data
,
ensure_ascii
=
False
)
msg_str
=
json
.
dumps
(
data
,
ensure_ascii
=
False
)
push_mq
(
msg_str
)
push_mq
(
msg_str
,
"liexin_nplm_filter_sku_data"
,
"liexin_nplm_filter_sku_data"
)
print
(
"push msg :
%
s"
%
msg_str
)
print
(
"push msg :
%
s"
%
msg_str
)
...
...
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