Fórum

MessageBUS

Stas Mias, modificado 11 Anos atrás.

MessageBUS

New Member Postagens: 2 Data de Entrada: 16/02/12 Postagens Recentes
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.
thumbnail
Mika Koivisto, modificado 11 Anos atrás.

RE: MessageBUS

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
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

			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.