CC-2631: Convert pypo to accept commands from RabbitMQ
- initial commit
This commit is contained in:
parent
4125f83ae7
commit
1c81d0d238
|
@ -31,7 +31,9 @@ class RabbitMq
|
|||
$EXCHANGE = 'airtime-schedule';
|
||||
$channel->exchange_declare($EXCHANGE, 'direct', false, true);
|
||||
|
||||
$data = json_encode(Schedule::GetScheduledPlaylists());
|
||||
$temp['event_type'] = "update_schedule";
|
||||
$temp['schedule'] = Schedule::GetScheduledPlaylists();
|
||||
$data = json_encode($temp);
|
||||
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
|
||||
|
||||
$channel->basic_publish($msg, $EXCHANGE);
|
||||
|
|
|
@ -48,7 +48,13 @@ def handle_message(body, message):
|
|||
logger = logging.getLogger('fetch')
|
||||
global SCHEDULE_PUSH_MSG
|
||||
logger.info("Received schedule from RabbitMQ: " + message.body)
|
||||
SCHEDULE_PUSH_MSG = json.loads(message.body)
|
||||
|
||||
m = json.loads(message.body)
|
||||
command = m['event_type']
|
||||
logger.info("Handling command: " + command)
|
||||
|
||||
if(command == 'update_schedule'):
|
||||
SCHEDULE_PUSH_MSG = m['schedule']
|
||||
# ACK the message to take it off the queue
|
||||
message.ack()
|
||||
|
||||
|
|
Loading…
Reference in New Issue