Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch code to ActiveMQ Ingestor #6

Closed
dylanmcreynolds opened this issue Feb 29, 2024 · 1 comment
Closed

Switch code to ActiveMQ Ingestor #6

dylanmcreynolds opened this issue Feb 29, 2024 · 1 comment
Assignees

Comments

@dylanmcreynolds
Copy link
Member

For Diamond, we heard that we want to maybe use ActiveMQ from RabbitMQ.

For the ingestor, we need to swap the library we use, and were provided the following script:

from DLS_ResubmitterCore import DLS_ResubmitterCore
from collections import deque
from time import sleep
import stomp
import json


class ScanListener(stomp.ConnectionListener):
    
    def __init__(self):
        self.messages = deque()
        
    def on_error(self, headers, message):
        print('received an error %s' % message)
    
    def on_message(self, headers, message):
        ob = json.loads(message)
        #if (ob["status"] == "STARTED"):
        if (ob["status"] == "COMPLETE"):
            self.messages.append(ob["filePath"])


submitterCore = DLS_ResubmitterCore()
conn = stomp.Connection([("k11-control.diamond.ac.uk", 61613)])
scan_listener = ScanListener()

conn.set_listener('', scan_listener)
conn.start()
conn.connect()
conn.subscribe(destination='/topic/org.eclipse.scanning.status.topic', id=1, ack='auto')


print("Autoprocessing listener activated")


while True:
    if (scan_listener.messages):
        path = scan_listener.messages.popleft()
        try:
            submitterCore.ActiveMQdataProcessing(path)
        except:
            print('Failed to process file ' + path)

    sleep(1)
@dylanmcreynolds dylanmcreynolds self-assigned this Feb 29, 2024
@dylanmcreynolds
Copy link
Member Author

close by #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant