31 lines
819 B
Python
31 lines
819 B
Python
#!/usr/bin/env python
|
|
|
|
import stomp
|
|
import os
|
|
|
|
from src.utils.jsonLogger import log
|
|
|
|
class keys():
|
|
|
|
def __init__(self):
|
|
self.uri = os.getenv("AMQ_URL")
|
|
self.amqU = os.getenv("BROKER_USER")
|
|
self.amqP = os.getenv("BROKER_PASSWORD")
|
|
self.addr = self.uri.split(':')[0]
|
|
self.port = self.uri.split(':')[1]
|
|
|
|
def returnKeys(self):
|
|
return self.addr, self.port, self.amqU, self.amqP
|
|
|
|
def activeMQSender(message):
|
|
addr, port, mqUser, mqPass = keys().returnKeys()
|
|
|
|
log("Attempting Connection to Artemis...", 'INFO')
|
|
con = stomp.Connection([(addr, port)], auto_content_length=False)
|
|
con.connect( mqUser, mqPass, wait=True)
|
|
|
|
con.send("TweetSave", message, content_type="application/json", headers={"Content-Type":"application/json"})
|
|
|
|
con.disconnect()
|
|
|