mirror of
https://git.kotyczka.ch/developers/django.git
synced 2025-04-05 15:25:08 +02:00
queueing first steps
This commit is contained in:
parent
efaae13adf
commit
1238286602
Binary file not shown.
@ -1,2 +1,5 @@
|
||||
username = 'mqadmin'
|
||||
password = '3Mnj29jKBsFybc'
|
||||
username = 'smx'
|
||||
password = 'smx'
|
||||
|
||||
#username = 'mqadmin'
|
||||
#password = '3Mnj29jKBsFybc'
|
36
app/edit.py
36
app/edit.py
@ -4,36 +4,44 @@ import pika
|
||||
|
||||
from tkinter.filedialog import askopenfilename, asksaveasfilename
|
||||
|
||||
def send_queue_message(exchange_name):
|
||||
def send_queue_message():
|
||||
exchange_name = 'simple-editor'
|
||||
message_all = 'Sent from RabbitMQ'
|
||||
|
||||
print(message_all)
|
||||
credentials= pika.PlainCredentials(username= conf.username, password= conf.password)
|
||||
connection= pika.BlockingConnection(pika.ConnectionParameters(host='localhost', port=5672, credentials= credentials))
|
||||
channel= connection.channel()
|
||||
channel.exchange_declare(exchange = exchange_name, durable=True, exchange_type='topic')
|
||||
channel.exchange_declare(exchange = exchange_name, durable = True, exchange_type = 'topic')
|
||||
channel.queue_declare(queue = 'AllInfo')
|
||||
channel.queue_bind(exchange = exchange_name, queue='AllInfo', routing_key='All')
|
||||
message = txt_edit.get("1.0", tk.END)
|
||||
|
||||
channel.basic_publish(exchange = exchange_name, routing_key = 'All', body = message)
|
||||
txt = txt_edit.get("1.0", tk.END)
|
||||
channel.queue_bind(exchange = exchange_name, queue = 'AllInfo', routing_key = 'new')
|
||||
channel.basic_publish(exchange = exchange_name, routing_key = 'new', body = txt)
|
||||
channel.close()
|
||||
|
||||
def get_queue_message(exchange_name):
|
||||
def get_queue_message():
|
||||
exchange_name = 'simple-editor'
|
||||
credentials= pika.PlainCredentials(username= conf.username, password= conf.password)
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost', port=5672, credentials= credentials))
|
||||
channel = connection.channel()
|
||||
channel.exchange_declare(exchange_name, durable=True, exchange_type='topic')
|
||||
txt_edit.delete("1.0", tk.END)
|
||||
|
||||
def callbackFunctionForQueue(ch,method,properties,body):
|
||||
def callback(ch,method,properties,body):
|
||||
message = 'Message from Queue Part: ' + body.decode("utf-8")
|
||||
txt_edit.insert(tk.END, message)
|
||||
ch.basic_ack(delivery_tag = method.delivery_tag)
|
||||
|
||||
ch.basic_publish('exchange_not_exist', routing_key='new',cbody='Nope this is wrong')
|
||||
##ch.basic_ack(delivery_tag = method.delivery_tag + 1)
|
||||
# Display the message parts
|
||||
channel.basic_consume(queue='AllInfo', on_message_callback=callbackFunctionForQueue, auto_ack=True)
|
||||
channel.queue_bind(exchange = exchange_name, queue = 'AllInfo', routing_key = 'new')
|
||||
channel.basic_consume(queue='AllInfo', on_message_callback=callback, auto_ack=True)
|
||||
##channel.consume(queue = 'AllInfo')
|
||||
|
||||
# Close the channel and the connection
|
||||
channel.close()
|
||||
connection.close()
|
||||
message_all = 'Retrieved from RabbitMQ'
|
||||
print(message_all)
|
||||
|
||||
def open_file():
|
||||
"""Open a file for editing."""
|
||||
@ -66,14 +74,14 @@ window.title("Simple Text Editor")
|
||||
|
||||
window.rowconfigure(0, minsize=800, weight=1)
|
||||
window.columnconfigure(1, minsize=800, weight=1)
|
||||
exchange_name = 'simple-editor'
|
||||
|
||||
|
||||
txt_edit = tk.Text(window)
|
||||
frm_buttons = tk.Frame(window, relief=tk.RAISED, bd=2)
|
||||
btn_open = tk.Button(frm_buttons, text="Open", command=open_file)
|
||||
btn_save = tk.Button(frm_buttons, text="Save As...", command=save_file)
|
||||
btn_send = tk.Button(frm_buttons, text="Send", command=send_queue_message(exchange_name))
|
||||
btn_receive = tk.Button(frm_buttons, text="Receive", command=get_queue_message(exchange_name))
|
||||
btn_send = tk.Button(frm_buttons, text="Send", command=send_queue_message)
|
||||
btn_receive = tk.Button(frm_buttons, text="Receive", command=get_queue_message)
|
||||
|
||||
btn_open.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
|
||||
btn_save.grid(row=1, column=0, sticky="ew", padx=5)
|
||||
|
26
app/message_producer.py
Normal file
26
app/message_producer.py
Normal file
@ -0,0 +1,26 @@
|
||||
from proton import Message
|
||||
from proton.handlers import MessagingHandler
|
||||
from proton.reactor import Container
|
||||
|
||||
|
||||
class HelloWorld(MessagingHandler):
|
||||
def __init__(self, server, address):
|
||||
super(HelloWorld, self).__init__()
|
||||
self.server = server
|
||||
self.address = address
|
||||
|
||||
def on_start(self, event):
|
||||
conn = event.container.connect(self.server)
|
||||
event.container.create_receiver(conn, self.address)
|
||||
event.container.create_sender(conn, self.address)
|
||||
|
||||
def on_sendable(self, event):
|
||||
event.sender.send(Message(body="Hello World!"))
|
||||
event.sender.close()
|
||||
|
||||
def on_message(self, event):
|
||||
print(event.message.body)
|
||||
event.connection.close()
|
||||
|
||||
|
||||
Container(HelloWorld("localhost:5672", "examples")).run()
|
@ -1,8 +1,10 @@
|
||||
import pika, config
|
||||
import pika
|
||||
##import amqp
|
||||
import config
|
||||
#declaring the credentials needed for connection like host, port, username, password, exchange etc
|
||||
credentials= pika.PlainCredentials(username= config.username, password= config.password)
|
||||
connection= pika.BlockingConnection(pika.ConnectionParameters(host='localhost', port=5672, credentials= credentials))
|
||||
channel= connection.channel()
|
||||
connection= pika.BlockingConnection(pika.ConnectionParameters(host='localhost', port=61616, credentials= credentials))
|
||||
channel = connection.channel()
|
||||
channel.exchange_declare(exchange='pydev', durable=True, exchange_type='topic')
|
||||
channel.queue_declare(queue= 'A')
|
||||
channel.queue_bind(exchange='pydev', queue='A', routing_key='A')
|
||||
|
BIN
artemis/artemis-data/bindings/activemq-bindings-1.bindings
Normal file
BIN
artemis/artemis-data/bindings/activemq-bindings-1.bindings
Normal file
Binary file not shown.
BIN
artemis/artemis-data/bindings/activemq-bindings-2.bindings
Normal file
BIN
artemis/artemis-data/bindings/activemq-bindings-2.bindings
Normal file
Binary file not shown.
BIN
artemis/artemis-data/journal/activemq-data-1.amq
Normal file
BIN
artemis/artemis-data/journal/activemq-data-1.amq
Normal file
Binary file not shown.
BIN
artemis/artemis-data/journal/activemq-data-2.amq
Normal file
BIN
artemis/artemis-data/journal/activemq-data-2.amq
Normal file
Binary file not shown.
BIN
artemis/artemis-data/journal/server.lock
Normal file
BIN
artemis/artemis-data/journal/server.lock
Normal file
Binary file not shown.
0
artemis/artemis-data/journal/serverlock.1
Normal file
0
artemis/artemis-data/journal/serverlock.1
Normal file
0
artemis/artemis-data/journal/serverlock.2
Normal file
0
artemis/artemis-data/journal/serverlock.2
Normal file
27
artemis/docker-compose-amq.yml
Normal file
27
artemis/docker-compose-amq.yml
Normal file
@ -0,0 +1,27 @@
|
||||
version: "2.4"
|
||||
|
||||
services:
|
||||
artemis:
|
||||
image: docker.kotyczka.ch/artemis-adoptopenjdk-11 ##apache/activemq-artemis
|
||||
platform: linux/amd64
|
||||
container_name: amq-arte
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- ARTEMIS_USER=smx
|
||||
- ARTEMIS_PASSWORD=smx
|
||||
- ARTEMIS_MIN_MEMORY=1512M
|
||||
- ARTEMIS_MAX_MEMORY=3024M
|
||||
volumes:
|
||||
- "./artemis-data:/var/lib/artemis-instance/data:rw"
|
||||
ports:
|
||||
- 8161:8161
|
||||
- 61616:61616
|
||||
mem_limit: 512m
|
||||
mem_reservation: 256m
|
||||
networks:
|
||||
- ametiq
|
||||
volumes:
|
||||
artemis-data:
|
||||
networks:
|
||||
ametiq:
|
||||
external: true
|
1
start_virtual.sh
Executable file
1
start_virtual.sh
Executable file
@ -0,0 +1 @@
|
||||
source virtualenv/bin/activate
|
Loading…
x
Reference in New Issue
Block a user