Package io.goobi.viewer.controller.mq
Class MessageQueueManager
java.lang.Object
io.goobi.viewer.controller.mq.MessageQueueManager
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 Alpers
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMessageQueueManager(ActiveMQConfig config, IDAO dao) MessageQueueManager(ActiveMQConfig config, IDAO dao, Map<String, MessageHandler<MessageStatus>> instances) -
Method Summary
Modifier and TypeMethodDescriptionaddToQueue(ViewerMessage message) Adds the message to the internal message queue to be handled later.booleanclearQueue(String queueName) voidintcountMessagesBefore(String queueName, String messageType, String messageId) countMessagesInQueue(String queueName) voidcreateRegistry(int namingPort, RMIServerSocketFactory serverFactory) booleandeleteMessage(ViewerMessage ticket) booleandeleteMessage(String taskName, String messageId) intdeleteMessages(String type) org.apache.activemq.broker.BrokerServiceorg.apache.activemq.ActiveMQConnectiongetMessageById(String messageId) static StringgetQueueForMessageType(String taskName) getWaitingMessages(String messageType) handle(ViewerMessage message) Finds the appropriate MessageHandler for a message, lets the handler handle the message and update the message in the database.booleanvoidinit()booleanbooleaninitializeMessageServer(String address, int namingPort, int protocolPort) booleanChecks if the queue has been successfully initialized.static voidSends a notification to the "messageQueueState" WebSocket to update message lists in the admin backend.booleanpauseQueue(String queueName) booleanresumeQueue(String queueName) voidsetQueueRunning(boolean running) voidshutdown()org.apache.activemq.ActiveMQConnection
-
Field Details
-
QUEUE_NAME_VIEWER
- See Also:
-
QUEUE_NAME_PDF
- See Also:
-
QUEUE_NAME_FRONTEND
- See Also:
-
QUEUE_NAMES
-
-
Constructor Details
-
MessageQueueManager
- Throws:
DAOExceptionIOException
-
MessageQueueManager
-
MessageQueueManager
public MessageQueueManager(ActiveMQConfig config, IDAO dao, Map<String, MessageHandler<MessageStatus>> instances)
-
-
Method Details
-
init
-
shutdown
-
addToQueue
Adds the message to the internal message queue to be handled later.- Parameters:
message- message to add to the queue- Returns:
- Message ID
- Throws:
MessageQueueException
-
getQueueForMessageType
-
notifyMessageQueueStateUpdate
public static void notifyMessageQueueStateUpdate()Sends a notification to the "messageQueueState" WebSocket to update message lists in the admin backend. -
handle
Finds the appropriate MessageHandler for a message, lets the handler handle the message and update the message in the database.- Parameters:
message- message to dispatch to its handler- Returns:
- the result of the handler calling the message
-
initializeMessageServer
public boolean initializeMessageServer() -
initializeMessageServer
-
createRegistry
public void createRegistry(int namingPort, RMIServerSocketFactory serverFactory) throws RemoteException - Throws:
RemoteException
-
closeMessageServer
public void closeMessageServer() -
getMessageById
-
getBroker
public org.apache.activemq.broker.BrokerService getBroker() -
isQueueRunning
public boolean isQueueRunning()Checks if the queue has been successfully initialized.- Returns:
- true if the queue is running
-
setQueueRunning
public void setQueueRunning(boolean running) -
countMessagesInQueue
-
countMessagesBefore
-
startConnection
- Throws:
JMSException
-
getConnection
- Throws:
JMSException
-
pauseQueue
-
resumeQueue
-
clearQueue
-
getWaitingMessages
-
deleteMessage
-
deleteMessage
-
deleteMessages
-
hasConfig
public boolean hasConfig() -
getListeners
-