@Override public void writeLine(String line) throws IOException { if (outputEnabled) { double rate; if (maxEventRateChecker.updateAndCheckRate() && (rate = maxEventRateChecker.getRate()) > maxLogsRate) { outputEnabled = false; final String message = String.format( "[WARNING] Application '%s' has exceeded output rate of %.2f messages / second. Application output has been disabled.", project.startsWith("/") ? project.substring(1) : project, rate); eventService.publish( RunnerEvent.messageLoggedEvent( processId, workspace, project, new RunnerEvent.LoggedMessage(message, lineCounter.getAndIncrement()))); return; } if (line != null) { eventService.publish( RunnerEvent.messageLoggedEvent( processId, workspace, project, new RunnerEvent.LoggedMessage(line, lineCounter.getAndIncrement()))); } } super.writeLine(line); }
@Test public void shouldPublishStackPersistedEventAfterStackIsPersisted() throws Exception { final boolean[] isNotified = new boolean[] {false}; eventService.subscribe(event -> isNotified[0] = true, StackPersistedEvent.class); stackDao.create(createStack("test", "test")); assertTrue(isNotified[0], "Event subscriber notified"); }
@PreDestroy void stop() { eventService.unsubscribe(projectCreatedEventSubscriber); }
@PostConstruct void start() { eventService.subscribe(projectCreatedEventSubscriber); }
@PreDestroy public void unsubscribe() { eventService.unsubscribe(this, BeforeUserRemovedEvent.class); }
@PostConstruct public void subscribe() { eventService.subscribe(this, BeforeUserRemovedEvent.class); }
@PreRemove private void preRemove(RecipeImpl recipe) { eventService.publish(new BeforeRecipeRemovedEvent(recipe)); }