Foren
MessageBUS
Stas Mias, geändert vor 11 Jahren.
MessageBUS
New Member Beiträge: 2 Beitrittsdatum: 16.02.12 Neueste Beiträge
Hi All .
My goal is to use message bus in both sync and async ways.
For async , I know I have to set and wire "messageListener" and "messageSender" for both sides .
What about sync messages ?
what is the correct implementation of the MessageListener for sending back sync response ?
thanks.
p.s. code example will be very useful.
My goal is to use message bus in both sync and async ways.
For async , I know I have to set and wire "messageListener" and "messageSender" for both sides .
What about sync messages ?
what is the correct implementation of the MessageListener for sending back sync response ?
thanks.
p.s. code example will be very useful.
Mika Koivisto, geändert vor 11 Jahren.
RE: MessageBUS
Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
If you want to send a message synchronously you just need to use MessageBusUtil.sendSynchronousMessage() method. The code snippet below is from com.liferay.portlet.documentlibrary.util.PDFProcessorImpl
As you can see it uses the same destination but in one case sends the message synchronously and in another asynchronously.
if (PropsValues.DL_FILE_ENTRY_PROCESSORS_TRIGGER_SYNCHRONOUSLY) {
try {
MessageBusUtil.sendSynchronousMessage(
DestinationNames.DOCUMENT_LIBRARY_PDF_PROCESSOR,
fileVersion);
}
catch (MessageBusException mbe) {
if (_log.isWarnEnabled()) {
_log.warn(mbe, mbe);
}
}
}
else {
MessageBusUtil.sendMessage(
DestinationNames.DOCUMENT_LIBRARY_PDF_PROCESSOR,
fileVersion);
}
As you can see it uses the same destination but in one case sends the message synchronously and in another asynchronously.