@Override protected void doResume(final NotificationListener listener) { listener.onProjectCreation(this,super.getEvent()); } };
/** * {@inheritDoc} */ @Override public final SuspendedNotification suspend(final AcknowledgeableNotification notification, final String payload) throws IOException { return createPropagator( notification, EventUtil.unmarshall(payload, this.clazz)); }
@Override protected void doResume(final NotificationListener listener) { listener.onContributorCreation(this, super.getEvent()); } };
/** * The a durable topic exchange is always declared */ private void declareExchange() throws ControllerException { try { this.manager.channel().exchangeDeclare(this.collector.getExchangeName(),EXCHANGE_TYPE,true); } catch (final IOException e) { if(!FailureAnalyzer.isExchangeDeclarationRecoverable(e)) { throw new ControllerException(this.collector.getBrokerHost(),this.collector.getBrokerPort(),this.collector.getVirtualHost(),"Could not create exchange named '"+this.collector.getExchangeName()+"'",e); } } }
private void bindQueue(final String queueName) throws ControllerException { try { this.manager.channel().queueBind(queueName,this.collector.getExchangeName(),Notifications.ROUTING_KEY_PATTERN); this.cleaners.push(CleanerFactory.queueUnbind(this.collector.getExchangeName(),queueName,Notifications.ROUTING_KEY_PATTERN)); } catch (final IOException e) { throw new ControllerException(this.collector.getBrokerHost(),this.collector.getBrokerPort(),this.collector.getVirtualHost(),"Could not bind queue '"+queueName+"' to exchange '"+this.collector.getExchangeName()+"' using routing key '"+Notifications.ROUTING_KEY_PATTERN+"'",e); } }
NotificationConsumer(final Channel channel, final BlockingQueue<SuspendedNotification> pendingNotifications) { super(channel); this.notifications = pendingNotifications; this.handlers= ImmutableList. <NotificationHandler>builder(). add(new ContributorCreatedNotificationHandler()). add(new ContributorDeletedNotificationHandler()). add(new CommitCreatedNotificationHandler()). add(new CommitDeletedNotificationHandler()). add(new ProjectCreatedNotificationHandler()). add(new ProjectDeletedNotificationHandler()). add(new ProjectUpdatedNotificationHandler()). build(); }
void publishEvent(final Event event) throws ControllerException { try { publishEvent(EventUtil.marshall(event), event.getClass().getSimpleName()); } catch (final IOException e) { throw new ControllerException( this.collector.getBrokerHost(), this.collector.getBrokerPort(), this.collector.getVirtualHost(), "Could not serialize event "+event, e); } }
private CollectorController startController(final CollectorConfiguration collector, final String queueName) throws ControllerException { final CollectorController controller = CollectorController.createNamedReceiver(collector,queueName,this.notificationQueue); LOGGER.info("Connecting controller for collector {}...",collector.getInstance()); try { controller.connect(); return controller; } catch (final ControllerException e) { LOGGER.warn("Could not connect controller for collector {}. Full stacktrace follows",collector.getInstance(),e); shutdownGracefully(); throw e; } }
private void disconnectGracefully() { if(this.manager.isConnected()) { cleanUp(); this.callbacks.clear(); this.actualQueueName=null; this.manager.disconnect(); } }
@Override protected void doResume(final NotificationListener listener) { listener.onCommitDeletion(this,super.getEvent()); } };
@Override protected void doResume(final NotificationListener listener) { listener.onProjectDeletion(this,super.getEvent()); } };
@Override protected void doResume(final NotificationListener listener) { listener.onProjectUpdate(this,super.getEvent()); } };
@Override protected void doResume(final NotificationListener listener) { listener.onContributorDeletion(this,super.getEvent()); } };
@Override protected void doResume(final NotificationListener listener) { listener.onCommitCreation(this, super.getEvent()); } };
/** * {@inheritDoc} */ @Override public final void resume(final NotificationListener listener) { try { doResume(listener); } finally { enforceAcknowledgement(); } }
private void createChannel() throws ControllerException { try { this.channel = createNewChannel(); } catch (final ControllerException e) { closeConnectionQuietly(); throw e; } }
static CollectorController createNamedReceiver(final CollectorConfiguration collector, final String queueName, final BlockingQueue<SuspendedNotification> queue) { Amqp.validateName(queueName,"Queue name"); checkNotNull(queue,"Notification queue cannot be null"); return new CollectorController(collector,queueName,queue); }
/** * {@inheritDoc} */ @Override public void discard(final Throwable exception) { this.notification.discard(exception); }
/** * {@inheritDoc} */ @Override public void consume() { this.notification.consume(); }
private NotificationPublisher(final CollectorConfiguration configuration) { this.configuration = configuration; this.controller=CollectorController.createPublisher(configuration); }