private synchronized Cluster clusterFor(EventListener eventListener) { Cluster cluster = clusterSelector.selectCluster(eventListener); if (cluster == null) { Class listenerType = eventListener.getClass(); if (eventListener instanceof EventListenerProxy) { listenerType = ((EventListenerProxy) eventListener).getTargetType(); } throw new EventListenerSubscriptionFailedException( format( "Unable to subscribe [%s] to the Event Bus. There is no suitable cluster for it. " + "Make sure the ClusterSelector is configured properly", listenerType.getName())); } if (clusters.add(cluster)) { terminal.onClusterCreated(cluster); } return cluster; }
@Override public void publish(EventMessage... events) { terminal.publish(events); }