Class MessageQueueManager

java.lang.Object
io.goobi.viewer.controller.mq.MessageQueueManager

@Singleton @Startup public class MessageQueueManager extends Object
Manages handling of messages by their respective MessageHandlers. Main method is handle(ViewerMessage message) which accepts a ViewerMessage and calls a MessageHandler instance to process the message, returning a MessageStatus result. #handle may either be called directly to handle the message instantly, or from a MessageQueue
Author:
florian
  • Field Details

  • Constructor Details

  • Method Details

    • init

      @PostConstruct public void init()
    • shutdown

      @PreDestroy public void shutdown()
    • addToQueue

      public String addToQueue(ViewerMessage message) throws MessageQueueException
      Add the message to the internal message queue to be handled later.
      Parameters:
      message -
      Returns:
      Message ID
      Throws:
      MessageQueueException
    • getQueueForMessageType

      public static String getQueueForMessageType(String taskName)
    • notifyMessageQueueStateUpdate

      public static void notifyMessageQueueStateUpdate()
      Send a notification to the "messageQueueState" WebSocket to update message lists in the admin backend.
    • handle

      public MessageStatus handle(ViewerMessage message)
      Finds the appropriate MessageHandler for a message, lets the handler handle the message and update the message in the database.
      Parameters:
      message -
      Returns:
      the result of the handler calling the message
    • initializeMessageServer

      public boolean initializeMessageServer()
    • initializeMessageServer

      public boolean initializeMessageServer(String address, int namingPort, int protocolPort)
    • createRegistry

      public void createRegistry(int namingPort, RMIServerSocketFactory serverFactory) throws RemoteException
      Throws:
      RemoteException
    • closeMessageServer

      public void closeMessageServer()
    • getMessageById

      public Optional<ViewerMessage> getMessageById(String messageId)
    • getBroker

      public org.apache.activemq.broker.BrokerService getBroker()
    • isQueueRunning

      public boolean isQueueRunning()
      Check if the queue has been successfully initialized.
      Returns:
      true if the queue is running
    • setQueueRunning

      public void setQueueRunning(boolean running)
    • countMessagesInQueue

      public Map<String,Integer> countMessagesInQueue(String queueName)
    • countMessagesBefore

      public int countMessagesBefore(String queueName, String messageType, String messageId)
    • startConnection

      public org.apache.activemq.ActiveMQConnection startConnection() throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • getConnection

      public org.apache.activemq.ActiveMQConnection getConnection() throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • pauseQueue

      public boolean pauseQueue(String queueName)
    • resumeQueue

      public boolean resumeQueue(String queueName)
    • clearQueue

      public boolean clearQueue(String queueName)
    • getWaitingMessages

      public List<ViewerMessage> getWaitingMessages(String messageType)
    • deleteMessage

      public boolean deleteMessage(ViewerMessage ticket)
    • deleteMessage

      public boolean deleteMessage(String taskName, String messageId)
    • deleteMessages

      public int deleteMessages(String type)
    • hasConfig

      public boolean hasConfig()
    • getListeners

      public List<DefaultQueueListener> getListeners()