List of usage examples for com.liferay.portal.kernel.messaging MessageBus getDestination
public Destination getDestination(String destinationName);
From source file:com.liferay.adaptive.media.image.internal.test.util.DestinationReplacer.java
License:Open Source License
public DestinationReplacer(String destinationName) { MessageBus messageBus = MessageBusUtil.getMessageBus(); _destination = messageBus.getDestination(destinationName); SynchronousDestination synchronousDestination = new SynchronousDestination(); synchronousDestination.setName(destinationName); messageBus.replace(synchronousDestination); }
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 v a 2s . 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); } }