Publishes a message to rabbit MQ. For now its using the default actions exchange. But we can modify this wrapper to include more paremeters for the exchange name. :param message: :param routing_key: :param exchange: :return:
(self,
message: dict,
routing_key: str,
exchange: str)
| 60 | exchange_type = ExchangeType.direct.value) |
| 61 | |
| 62 | def send_message(self, |
| 63 | message: dict, |
| 64 | routing_key: str, |
| 65 | exchange: str): |
| 66 | """ |
| 67 | Publishes a message to rabbit MQ. For now its using the default |
| 68 | actions exchange. But we can modify this wrapper to include more paremeters |
| 69 | for the exchange name. |
| 70 | :param message: |
| 71 | :param routing_key: |
| 72 | :param exchange: |
| 73 | :return: |
| 74 | """ |
| 75 | self.main_channel.basic_publish( |
| 76 | exchange = exchange, |
| 77 | routing_key = routing_key, |
| 78 | body = json.dumps(message).encode('utf-8'), |
| 79 | properties = pika.BasicProperties(content_type = 'application/json')) |
no outgoing calls
no test coverage detected