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
-
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) Add 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) booleanCheck if the queue has been successfully initialized.static voidSend 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
@PostConstruct public void init() -
shutdown
@PreDestroy public void shutdown() -
addToQueue
Add the message to the internal message queue to be handled later.- Parameters:
message-- Returns:
- Message ID
- Throws:
MessageQueueException
-
getQueueForMessageType
-
notifyMessageQueueStateUpdate
public static void notifyMessageQueueStateUpdate()Send 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-- 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()Check if the queue has been successfully initialized.- Returns:
- true if the queue is running
-
setQueueRunning
public void setQueueRunning(boolean running) -
countMessagesInQueue
-
countMessagesBefore
-
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
-
resumeQueue
-
clearQueue
-
getWaitingMessages
-
deleteMessage
-
deleteMessage
-
deleteMessages
-
hasConfig
public boolean hasConfig() -
getListeners
-