2025-02-07 22:55:54 -05:00
|
|
|
import stomp
|
|
|
|
|
import time
|
|
|
|
|
import SullyGnomeRobot
|
|
|
|
|
import RestAPIClient
|
2025-02-13 13:37:53 -05:00
|
|
|
import os
|
|
|
|
|
import signal
|
2025-02-07 22:55:54 -05:00
|
|
|
|
|
|
|
|
print("## ")
|
|
|
|
|
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
|
|
|
|
print("## ")
|
|
|
|
|
|
|
|
|
|
class MyListener(stomp.ConnectionListener):
|
|
|
|
|
|
|
|
|
|
def on_message(headers, message):
|
|
|
|
|
|
|
|
|
|
print("** new message! **")
|
|
|
|
|
|
|
|
|
|
print("message / ", message)
|
|
|
|
|
|
|
|
|
|
print("messagebody / ", message.body)
|
|
|
|
|
|
|
|
|
|
print("checking the value does or doesnt exist in db")
|
|
|
|
|
|
|
|
|
|
alreadyExistsSuccess = RestAPIClient.searchURLSuccesses(message.body)
|
|
|
|
|
|
|
|
|
|
print("alreadyExistsSuccess / ", alreadyExistsSuccess)
|
|
|
|
|
|
|
|
|
|
if alreadyExistsSuccess.lower().strip() == "true":
|
|
|
|
|
|
|
|
|
|
print("this record exists (successes). returning. doing nothing")
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
print("didn't exist in success. check in errors now.")
|
|
|
|
|
|
|
|
|
|
alreadyExistsFailure = RestAPIClient.searchURLFailures(message.body)
|
|
|
|
|
|
|
|
|
|
print("alreadyExistsFailure / ", alreadyExistsFailure)
|
|
|
|
|
|
|
|
|
|
if alreadyExistsFailure.lower().strip() == "true":
|
|
|
|
|
|
|
|
|
|
print("this record exists (failures). returning. doing nothing")
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
print("didn't exist in success or errors. will process now")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
SullyGnomeRobot.download(message.body)
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
|
|
print(f"exception / something went wrong when the sully gnome robot was downloading: {e}")
|
|
|
|
|
|
2025-02-12 11:06:22 -05:00
|
|
|
RestAPIClient.addDownloadFailure(message.body, e)
|
2025-02-07 22:55:54 -05:00
|
|
|
|
|
|
|
|
def on_error(headers, message):
|
|
|
|
|
|
|
|
|
|
print('received an error "%s"' % message)
|
|
|
|
|
|
2025-02-12 11:06:22 -05:00
|
|
|
RestAPIClient.addDownloadFailure(message.body, "error from onmessage (consumer.py)")
|
2025-02-07 22:55:54 -05:00
|
|
|
|
|
|
|
|
print("## ")
|
2025-02-13 13:37:53 -05:00
|
|
|
print("## starting > (timed) JMS consumer (yankee-sully-channels-monthly)")
|
2025-02-07 22:55:54 -05:00
|
|
|
print("## ")
|
|
|
|
|
|
2025-02-13 13:37:53 -05:00
|
|
|
|
2025-02-09 19:52:26 -05:00
|
|
|
conn = stomp.Connection([('67.220.70.106', 61613)])
|
2025-02-07 22:55:54 -05:00
|
|
|
|
|
|
|
|
conn.set_listener('', MyListener())
|
|
|
|
|
|
|
|
|
|
conn.connect('admin', 'password', wait=True)
|
|
|
|
|
|
|
|
|
|
conn.subscribe('/queue/yankee-sully-channels-monthly', id=1, ack='auto', headers={'activemq.prefetchSize': 10})
|
|
|
|
|
|
|
|
|
|
print("## ")
|
2025-02-07 22:57:23 -05:00
|
|
|
print("## notification > connected to JMS server (yankee-sully-channels-monthly) 3333")
|
2025-02-07 22:55:54 -05:00
|
|
|
print("## ")
|
|
|
|
|
|
2025-02-13 13:37:53 -05:00
|
|
|
start_time = time.time()
|
|
|
|
|
|
|
|
|
|
print("start time /",start_time)
|
|
|
|
|
|
|
|
|
|
counter=0
|
|
|
|
|
|
|
|
|
|
while time.time() - start_time < 60:
|
|
|
|
|
|
|
|
|
|
counter = counter + 1
|
2025-02-07 22:55:54 -05:00
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
2025-02-13 13:37:53 -05:00
|
|
|
print("waiting for 60 seconds of elapsed time: ",counter)
|
|
|
|
|
|
2025-02-07 22:55:54 -05:00
|
|
|
time.sleep(1)
|
2025-02-13 13:37:53 -05:00
|
|
|
|
|
|
|
|
print("it's been 60 seconds. what up though?")
|
2025-02-07 22:55:54 -05:00
|
|
|
|
|
|
|
|
conn.disconnect()
|
2025-02-13 13:37:53 -05:00
|
|
|
|
|
|
|
|
print("disconnected from JMS. i'll holla!")
|