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
-
Constructor Summary
ConstructorDescriptionMessageQueueManager
(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.boolean
clearQueue
(String queueName) void
int
countMessagesBefore
(String queueName, String messageType, String messageId) countMessagesInQueue
(String queueName) void
createRegistry
(int namingPort, RMIServerSocketFactory serverFactory) boolean
deleteMessage
(ViewerMessage ticket) boolean
deleteMessage
(String taskName, String messageId) int
deleteMessages
(String type) org.apache.activemq.broker.BrokerService
org.apache.activemq.ActiveMQConnection
getMessageById
(String messageId) static String
getQueueForMessageType
(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.boolean
void
init()
boolean
boolean
initializeMessageServer
(String address, int namingPort, int protocolPort) boolean
Check if the queue has been successfully initialized.static void
Send a notification to the "messageQueueState" WebSocket to update message lists in the admin backend.boolean
pauseQueue
(String queueName) boolean
resumeQueue
(String queueName) void
setQueueRunning
(boolean running) void
shutdown()
org.apache.activemq.ActiveMQConnection
-
Field Details
-
QUEUE_NAME_VIEWER
- See Also:
-
QUEUE_NAME_PDF
- See Also:
-
-
Constructor Details
-
MessageQueueManager
- Throws:
DAOException
IOException
-
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
-