Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
13
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
rabbitmq_agents
Commits
b8c7d6bd
Unverified
Commit
b8c7d6bd
authored
2 years ago
by
Ravi Tripathi
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #111 from diedpigs/feat-update-rcrmq
Update rcrmq class
parents
3e80846f
9e2f78c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!147
Merge previous default branch feat-cod-rmq into main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rc_rmq.py
+32
-26
32 additions, 26 deletions
rc_rmq.py
with
32 additions
and
26 deletions
rc_rmq.py
+
32
−
26
View file @
b8c7d6bd
...
...
@@ -13,9 +13,6 @@ class RCRMQ(object):
VHOST
=
"
/
"
EXCHANGE
=
""
EXCHANGE_TYPE
=
"
direct
"
QUEUE
=
None
DURABLE
=
True
ROUTING_KEY
=
None
DEBUG
=
False
def
__init__
(
self
,
config
=
None
,
debug
=
False
):
...
...
@@ -83,55 +80,64 @@ class RCRMQ(object):
durable
=
True
,
)
def
bind_queue
(
self
):
self
.
_channel
.
queue_declare
(
queue
=
self
.
QUEUE
,
durable
=
self
.
DURABLE
)
def
bind_queue
(
self
,
queue
=
""
,
routing_key
=
None
,
durable
=
True
,
exclusive
=
False
):
if
self
.
_connection
is
None
:
self
.
connect
()
result
=
self
.
_channel
.
queue_declare
(
queue
=
queue
,
durable
=
durable
,
exclusive
=
exclusive
)
self
.
_channel
.
queue_bind
(
exchange
=
self
.
EXCHANGE
,
queue
=
self
.
QUEUE
,
routing_key
=
self
.
ROUTING_KEY
,
queue
=
result
.
method
.
queue
,
routing_key
=
routing_key
,
)
return
result
.
method
.
queue
def
disconnect
(
self
):
self
.
_channel
.
close
()
self
.
_connection
.
close
()
self
.
_connection
=
None
def
delete_queue
(
self
):
self
.
_channel
.
queue_delete
(
self
.
QUEUE
)
def
delete_queue
(
self
,
queue
):
self
.
_channel
.
queue_delete
(
queue
)
def
publish_msg
(
self
,
obj
):
if
"
routing_key
"
in
obj
:
self
.
ROUTING_KEY
=
obj
[
"
routing_key
"
]
routing_key
=
obj
.
get
(
"
routing_key
"
)
props
=
obj
.
get
(
"
props
"
)
if
self
.
_connection
is
None
:
self
.
connect
()
self
.
_channel
.
basic_publish
(
exchange
=
self
.
EXCHANGE
,
routing_key
=
self
.
ROUTING_KEY
,
routing_key
=
routing_key
,
properties
=
props
,
body
=
json
.
dumps
(
obj
[
"
msg
"
]),
)
def
start_consume
(
self
,
obj
):
if
"
queue
"
in
obj
:
self
.
QUEUE
=
obj
[
"
queue
"
]
self
.
ROUTING_KEY
=
(
obj
[
"
routing_key
"
]
if
"
routing_key
"
in
obj
else
self
.
QUEUE
)
if
"
durable
"
in
obj
:
self
.
DURABLE
=
obj
[
"
durable
"
]
if
self
.
DEBUG
:
print
(
"
Queue:
"
+
self
.
QUEUE
+
"
\n
Routing_key:
"
+
self
.
ROUTING_KEY
)
queue
=
obj
.
get
(
"
queue
"
,
""
)
routing_key
=
obj
.
get
(
"
routing_key
"
,
queue
or
None
)
durable
=
obj
.
get
(
"
durable
"
,
True
)
exclusive
=
obj
.
get
(
"
exclusive
"
,
False
)
bind
=
obj
.
get
(
"
bind
"
,
True
)
if
self
.
_connection
is
None
:
self
.
connect
()
self
.
bind_queue
()
if
bind
:
self
.
bind_queue
(
queue
,
routing_key
,
durable
,
exclusive
)
if
self
.
DEBUG
:
print
(
"
Queue:
"
+
queue
+
"
\n
Routing_key:
"
+
routing_key
)
self
.
_consumer_tag
=
self
.
_channel
.
basic_consume
(
self
.
QUEUE
,
obj
[
"
cb
"
])
self
.
_consumer_tag
=
self
.
_channel
.
basic_consume
(
queue
,
obj
[
"
cb
"
])
self
.
_consuming
=
True
try
:
self
.
_channel
.
start_consuming
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment