automated terminal push
This commit is contained in:
79
consumer.py
79
consumer.py
@@ -3,45 +3,80 @@ import time
|
||||
import SullyGnomeRobot
|
||||
import RestAPIClient
|
||||
|
||||
### start variables ###
|
||||
|
||||
jmsQueue="asian-tester"
|
||||
|
||||
host = '38.107.226.34'
|
||||
|
||||
port = 61613
|
||||
|
||||
|
||||
username = 'admin'
|
||||
password = 'password'
|
||||
|
||||
|
||||
### end variables ###
|
||||
|
||||
print("## ")
|
||||
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
||||
print(f"## starting > JMS consumer app!")
|
||||
print("## ")
|
||||
|
||||
## https://sullygnome.com/channel/yaritaiji/2024october/games
|
||||
def writeSullyURLToJMS():
|
||||
|
||||
channel="https://sullygnome.com/channel/yaritaiji/2024october/games"
|
||||
|
||||
print(f"launch -> jms writer -> channel-> {channel}")
|
||||
|
||||
conn = stomp.Connection([('osiris.yankee.embanet.online', 61613)])
|
||||
|
||||
conn.connect('admin', 'password', wait=True)
|
||||
|
||||
try:
|
||||
|
||||
conn.send(body=channel.strip(), destination=f'/queue/{jmsQueue}')
|
||||
|
||||
finally:
|
||||
|
||||
conn.disconnect()
|
||||
|
||||
class MyListener(stomp.ConnectionListener):
|
||||
|
||||
def on_message(headers, message):
|
||||
|
||||
print("** new message! **")
|
||||
## print("** new message! **")
|
||||
|
||||
print("message / ", message)
|
||||
## print("message / ", message)
|
||||
|
||||
print("messagebody / ", message.body)
|
||||
print("JMS url -> ", message.body)
|
||||
|
||||
print("checking the value does or doesnt exist in db")
|
||||
## print("checking the value does or doesnt exist in db")
|
||||
|
||||
alreadyExistsSuccess = RestAPIClient.searchURLSuccesses(message.body)
|
||||
|
||||
print("alreadyExistsSuccess / ", alreadyExistsSuccess)
|
||||
## print("alreadyExistsSuccess / ", alreadyExistsSuccess)
|
||||
|
||||
if alreadyExistsSuccess.lower().strip() == "true":
|
||||
|
||||
print("this record exists (successes). returning. doing nothing")
|
||||
## print("this record exists (successes). returning. doing nothing")
|
||||
|
||||
return
|
||||
## return
|
||||
|
||||
print("didn't exist in success. check in errors now.")
|
||||
print ("skipped!!")
|
||||
|
||||
## print("didn't exist in success. check in errors now.")
|
||||
|
||||
alreadyExistsFailure = RestAPIClient.searchURLFailures(message.body)
|
||||
|
||||
print("alreadyExistsFailure / ", alreadyExistsFailure)
|
||||
## print("alreadyExistsFailure / ", alreadyExistsFailure)
|
||||
|
||||
if alreadyExistsFailure.lower().strip() == "true":
|
||||
|
||||
print("this record exists (failures). returning. doing nothing")
|
||||
## print("this record exists (failures). returning. doing nothing")
|
||||
|
||||
return
|
||||
##return
|
||||
|
||||
print ("skipped!!")
|
||||
|
||||
print("didn't exist in success or errors. will process now")
|
||||
|
||||
@@ -62,19 +97,24 @@ class MyListener(stomp.ConnectionListener):
|
||||
RestAPIClient.addDownloadFailure(message.body, "error from onmessage (consumer.py)")
|
||||
|
||||
print("## ")
|
||||
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
||||
print(f"## starting > JMS consumer ([{jmsQueue}]")
|
||||
print("## ")
|
||||
|
||||
conn = stomp.Connection([('38.107.226.34', 61613)])
|
||||
writeSullyURLToJMS()
|
||||
connection_details = [(host, port)]
|
||||
|
||||
conn = stomp.Connection(connection_details)
|
||||
|
||||
conn.set_listener('', MyListener())
|
||||
|
||||
conn.connect('admin', 'password', wait=True)
|
||||
conn.connect(username, password, wait=True)
|
||||
|
||||
conn.subscribe('/queue/yankee-sully-channels-monthly', id=1, ack='auto', headers={'activemq.prefetchSize': 10})
|
||||
conn.subscribe(f'/queue/{jmsQueue}', id=1, ack='auto', headers={'activemq.prefetchSize': 10})
|
||||
|
||||
print(f"Subscribed to queue: {jmsQueue}")
|
||||
|
||||
print("## ")
|
||||
print("## notification > connected to JMS server (yankee-sully-channels-monthly) 456")
|
||||
print(f"## notification > connected to JMS server [{jmsQueue}] (upgrade)")
|
||||
print("## ")
|
||||
|
||||
while True:
|
||||
@@ -82,5 +122,6 @@ while True:
|
||||
pass
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
conn.disconnect()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user