Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Flask_User_Reg
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Krish Moodbidri
Flask_User_Reg
Commits
9c672f7c
Commit
9c672f7c
authored
5 years ago
by
Mitchell Moore
Browse files
Options
Downloads
Patches
Plain Diff
Add comments and display routing to manager
parent
ac267069
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
message_manager.py
+7
-7
7 additions, 7 deletions
message_manager.py
ohpc_consumer.py
+8
-7
8 additions, 7 deletions
ohpc_consumer.py
ood_consumer.py
+11
-7
11 additions, 7 deletions
ood_consumer.py
test_producer.py
+2
-1
2 additions, 1 deletion
test_producer.py
with
28 additions
and
22 deletions
message_manager.py
+
7
−
7
View file @
9c672f7c
#!/usr/bin/env python
import
pika
import
pika
# python client
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'
localhost
'
))
pika
.
ConnectionParameters
(
host
=
'
localhost
'
))
# connecting to a broker on the local machine
channel
=
connection
.
channel
()
channel
.
exchange_declare
(
exchange
=
'
direct_logs
'
,
exchange_type
=
'
direct
'
)
channel
.
exchange_declare
(
exchange
=
'
direct_logs
'
,
exchange_type
=
'
direct
'
)
# create exchange to pass messages
result
=
channel
.
queue_declare
(
queue
=
''
,
exclusive
=
True
)
queue_name
=
result
.
method
.
queue
queue_name
=
result
.
method
.
queue
# creates a random name for the newly generated queue
channel
.
queue_bind
(
exchange
=
'
direct_logs
'
,
queue
=
queue_name
,
routing_key
=
"
manager
"
)
exchange
=
'
direct_logs
'
,
queue
=
queue_name
,
routing_key
=
"
manager
"
)
# combine exchange, queue, and define routing name
print
(
'
[*] Waiting for logs. To exit press CTRL+C
'
)
...
...
@@ -22,6 +22,6 @@ def callback(ch, method, properties, body):
channel
.
basic_consume
(
queue
=
queue_name
,
on_message_callback
=
callback
,
auto_ack
=
True
)
queue
=
queue_name
,
on_message_callback
=
callback
,
auto_ack
=
True
)
# ingest messages, and assume delivered via auto_ack
channel
.
start_consuming
()
\ No newline at end of file
channel
.
start_consuming
()
# initiate message ingenstion
This diff is collapsed.
Click to expand it.
ohpc_consumer.py
+
8
−
7
View file @
9c672f7c
#!/usr/bin/env python
import
pika
import
pika
# python client
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'
localhost
'
))
pika
.
ConnectionParameters
(
host
=
'
localhost
'
))
# connecting to a broker on the local machine
channel
=
connection
.
channel
()
channel
.
exchange_declare
(
exchange
=
'
direct_logs
'
,
exchange_type
=
'
direct
'
)
channel
.
exchange_declare
(
exchange
=
'
direct_logs
'
,
exchange_type
=
'
direct
'
)
# create exchange to pass messages
result
=
channel
.
queue_declare
(
queue
=
''
,
exclusive
=
True
)
queue_name
=
result
.
method
.
queue
queue_name
=
result
.
method
.
queue
# creates a random name for the newly generated queue
channel
.
queue_bind
(
exchange
=
'
direct_logs
'
,
queue
=
queue_name
,
routing_key
=
"
ohpc
"
)
exchange
=
'
direct_logs
'
,
queue
=
queue_name
,
routing_key
=
"
ohpc
"
)
# combine exchange, queue, and define routing name
print
(
'
[*] Waiting for logs. To exit press CTRL+C
'
)
def
callback
(
ch
,
method
,
properties
,
body
):
print
(
"
[x] %r:%r
"
%
(
method
.
routing_key
,
body
))
# Todo: Make message manager more functional
channel
.
basic_consume
(
queue
=
queue_name
,
on_message_callback
=
callback
,
auto_ack
=
True
)
queue
=
queue_name
,
on_message_callback
=
callback
,
auto_ack
=
True
)
# ingest messages, and assume delivered via auto_ack
channel
.
start_consuming
()
\ No newline at end of file
channel
.
start_consuming
()
# initiate message ingenstion
This diff is collapsed.
Click to expand it.
ood_consumer.py
+
11
−
7
View file @
9c672f7c
#!/usr/bin/env python
import
pika
import
pika
# python client
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
host
=
'
localhost
'
))
pika
.
ConnectionParameters
(
host
=
'
localhost
'
))
# connecting to a broker on the local machine
channel
=
connection
.
channel
()
channel
.
exchange_declare
(
exchange
=
'
direct_logs
'
,
exchange_type
=
'
direct
'
)
channel
.
exchange_declare
(
exchange
=
'
direct_logs
'
,
exchange_type
=
'
direct
'
)
# create exchange to pass messages
result
=
channel
.
queue_declare
(
queue
=
''
,
exclusive
=
True
)
queue_name
=
result
.
method
.
queue
queue_name
=
result
.
method
.
queue
# creates a random name for the newly generated queue
channel
.
queue_bind
(
exchange
=
'
direct_logs
'
,
queue
=
queue_name
,
routing_key
=
"
ood
"
)
exchange
=
'
direct_logs
'
,
queue
=
queue_name
,
routing_key
=
"
ood
"
)
# combine exchange, queue, and define routing name
print
(
'
[*] Waiting for logs. To exit press CTRL+C
'
)
def
callback
(
ch
,
method
,
properties
,
body
):
message
=
"
ood sent this
"
channel
.
basic_publish
(
exchange
=
'
direct_logs
'
,
routing_key
=
"
manager
"
,
body
=
message
)
print
(
"
[x] %r:%r
"
%
(
method
.
routing_key
,
body
))
# Todo: Make message manager more functional
channel
.
basic_consume
(
queue
=
queue_name
,
on_message_callback
=
callback
,
auto_ack
=
True
)
queue
=
queue_name
,
on_message_callback
=
callback
,
auto_ack
=
True
)
# ingest messages, and assume delivered via auto_ack
channel
.
start_consuming
()
\ No newline at end of file
channel
.
start_consuming
()
# initiate message ingenstion
This diff is collapsed.
Click to expand it.
test_producer.py
+
2
−
1
View file @
9c672f7c
...
...
@@ -17,4 +17,5 @@ print(" [x] Sent %r:%r" % ("ohpc", message))
channel
.
basic_publish
(
exchange
=
'
direct_logs
'
,
routing_key
=
"
ood
"
,
body
=
message
)
print
(
"
[x] Sent %r:%r
"
%
(
"
ood
"
,
message
))
connection
.
close
()
\ No newline at end of file
connection
.
close
()
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