This website uses cookies to ensure you get the best experience. Learn More.
Liferay Message Bus
Destinations :
Destination Types:
Note : Liferay has preconfigured destinations for various purposes. The DestinationNames class defines String constants for each of them. For example,DestinationNames.DOCUMENT_LIBRARY_PDF_PROCESSOR (value is "liferay/document_library_pdf_processor") is for deployment event messages. Since destinations are tuned for specific purposes, don’t modify them.
Example : Create Message Bus Listener For Documents and Media
DocumentsAndMediaMessageBusListner.class
Senders : Once you’ve created a message, there are three ways to send it with the Message Bus:
Follow this steps to send message directly:
1) Get a MessageBus reference.
@Reference
MessageBus _messageBus;
2) Create a message.
Message message = new Message();
3) Call the MessageBus reference’s sendMessage method with the destination and message:
_messageBus.sendMessage(“destinationName”, message);
Direct Sending Example:
Asynchronous Sending Example:
Synchronous Sending : Blocks thread until receiving a response or the response times out.
Operation Modes :
Synchronous Sending Example:
Listener Registration Methods : Here are the ways to register your listener with Message Bus:
Automatic Registration as a component
That's IT! As per the above example, you can easily implement the message bus in Liferay.