-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update python-socketio version in requirements files
Update tag and release name for v1.0.7 Update tag and release name for v1.0.6 Update tag and release name for v1.0.5 Refactor EscPComandos.py to use the 'total' variable for printing the total amount Update tag and release name for v1.0.8 Update release name for v1.0.8 Update requirements.cli.txt and requirements.kivy.txt to include 'pika' Update requirements.txt to include 'pika' Refactor ComandosHandler.py to handle different data types for commands Update Configberry.py to print the config file path Add RabbitMQConsumer.py to handle consuming messages from RabbitMQ
- Loading branch information
Showing
8 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ argparse==1.4.0 | |
uuid==1.30 | ||
appdirs==1.4.4 | ||
platformdirs==4.2.2 | ||
pika |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ uuid==1.30 | |
appdirs==1.4.4 | ||
platformdirs==4.2.2 | ||
kivy==2.3.0 | ||
pika |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ kivy==2.3.0 | |
cython==3.0.11 | ||
buildozer==1.5.0 | ||
pyjnius==1.6.1 | ||
twisted==24.7.0 | ||
twisted==24.7.0 | ||
pika |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
|
||
import threading, os, pika | ||
|
||
from common.ComandosHandler import ComandosHandler, TraductorException | ||
from common.fiscalberry_logger import getLogger | ||
|
||
|
||
class RabbitMQConsumer: | ||
|
||
STREAM_NAME = "paxaprinter" | ||
|
||
# 5GB | ||
STREAM_RETENTION = 5000000000 | ||
|
||
def __init__(self, host, port, user, password, uuid): | ||
self.host = host | ||
self.port = port | ||
self.user = user | ||
self.password = password | ||
self.connection = None | ||
self.channel = None | ||
|
||
self.client_uuid = uuid | ||
|
||
# Configuro logger según ambiente | ||
environment = os.getenv('ENVIRONMENT', 'production') | ||
if environment == 'development': | ||
sioLogger = True | ||
else: | ||
sioLogger = False | ||
|
||
self.logger = getLogger() | ||
|
||
|
||
|
||
def start(self): | ||
|
||
connection = pika.BlockingConnection(pika.ConnectionParameters(host=self.host, port=self.port, credentials=pika.PlainCredentials(self.user, self.password))) | ||
channel = connection.channel() | ||
|
||
#channel.exchange_declare(exchange=self.STREAM_NAME, exchange_type='direct') | ||
queue_name = self.client_uuid | ||
channel.queue_declare(queue=queue_name) | ||
channel.queue_bind(exchange=self.STREAM_NAME, queue=queue_name, routing_key=self.client_uuid) | ||
|
||
def callback(ch, method, properties, body): | ||
comandoHandler = ComandosHandler() | ||
comandoHandler.send_command(body) | ||
|
||
channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True) | ||
print(f"Waiting for messages in queue: {queue_name}") | ||
channel.start_consuming() | ||
|
||
|
||
|