List of usage examples for com.liferay.portal.kernel.messaging MessageBusUtil addDestination
@Deprecated public static void addDestination(Destination destination)
From source file:com.liferay.alloy.mvc.BaseAlloyControllerImpl.java
License:Open Source License
protected void initMessageListener(String destinationName, MessageListener messageListener, boolean enableScheduler) { MessageBus messageBus = MessageBusUtil.getMessageBus(); Destination destination = messageBus.getDestination(destinationName); if (destination != null) { Set<MessageListener> messageListeners = destination.getMessageListeners(); for (MessageListener curMessageListener : messageListeners) { if (!(curMessageListener instanceof InvokerMessageListener)) { continue; }//from w ww .j a va2 s. c o m InvokerMessageListener invokerMessageListener = (InvokerMessageListener) curMessageListener; curMessageListener = invokerMessageListener.getMessageListener(); if (messageListener == curMessageListener) { return; } Class<?> messageListenerClass = messageListener.getClass(); String messageListenerClassName = messageListenerClass.getName(); Class<?> curMessageListenerClass = curMessageListener.getClass(); if (!messageListenerClassName.equals(curMessageListenerClass.getName())) { continue; } try { if (enableScheduler) { SchedulerEngineHelperUtil.unschedule(getSchedulerJobName(), getMessageListenerGroupName(), StorageType.MEMORY_CLUSTERED); } MessageBusUtil.unregisterMessageListener(destinationName, curMessageListener); } catch (Exception e) { log.error(e, e); } break; } } else { SerialDestination serialDestination = new SerialDestination(); serialDestination.setName(destinationName); serialDestination.open(); MessageBusUtil.addDestination(serialDestination); } try { MessageBusUtil.registerMessageListener(destinationName, messageListener); if (enableScheduler) { SchedulerEngineHelperUtil.schedule(getSchedulerTrigger(), StorageType.MEMORY_CLUSTERED, null, destinationName, null, 0); } } catch (Exception e) { log.error(e, e); } }
From source file:com.liferay.ipgeocoder.servlet.IPGeocoderServletContextListener.java
License:Open Source License
@Override protected void doPortalInit() { _ipGeocoderDestination = new ParallelDestination(DestinationNames.IP_GEOCODER); MessageBusUtil.addDestination(_ipGeocoderDestination); _ipGeocoderMessageListener = new IPGeocoderMessageListener(); _ipGeocoderDestination.register(_ipGeocoderMessageListener); Destination ipGeocoderResponseDestination = new ParallelDestination(DestinationNames.IP_GEOCODER_RESPONSE); MessageBusUtil.addDestination(ipGeocoderResponseDestination); }
From source file:com.liferay.ruon.servlet.RUONServletContextListener.java
License:Open Source License
public void portalInit() { _ruonDestination = new ParallelDestination(DestinationNames.RUON); MessageBusUtil.addDestination(_ruonDestination); _ruonMessageListener = new RUONMessageListener(); Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); try {//from w ww. j a va2 s . c om currentThread.setContextClassLoader(_classLoader); _ruonDestination.register(_ruonMessageListener); } finally { currentThread.setContextClassLoader(contextClassLoader); } Destination ruonResponseDestination = new ParallelDestination(DestinationNames.RUON_RESPONSE); MessageBusUtil.addDestination(ruonResponseDestination); }
From source file:com.liferay.sync.servlet.SyncServletContextListener.java
License:Open Source License
protected void registerMessageListener(MessageListener messageListener, String destinationName) { SerialDestination serialDestination = new SerialDestination(); serialDestination.setName(destinationName); serialDestination.afterPropertiesSet(); MessageBusUtil.addDestination(serialDestination); MessageBusUtil.registerMessageListener(destinationName, messageListener); }
From source file:org.vaadin.tori.util.LiferayToriActivityMessaging.java
License:Apache License
@Override public void register() { if (!MessageBusUtil.getMessageBus().hasDestination(TORI_DESTINATION)) { log.info("Adding a message bus destination: " + TORI_DESTINATION); @SuppressWarnings("deprecation") Destination destination = new ParallelDestination(TORI_DESTINATION); destination.open();//from w w w.j a va 2s .c o m MessageBusUtil.addDestination(destination); } MessageBusUtil.registerMessageListener(TORI_DESTINATION, this); }