@Override protected void messageHandled(ChannelHandlerContext ctx, NettyRxWebSocketSession session, Object message) { ctx.executor().execute(() -> { try { eventPublisher.publishEvent(new WebSocketMessageProcessedEvent<>(session, message)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Error publishing WebSocket message processed event: " + e.getMessage(), e); } } }); }
@Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { Channel channel = ctx.channel(); channel.attr(NettyRxWebSocketSession.WEB_SOCKET_SESSION_KEY).set(null); if (LOG.isDebugEnabled()) { LOG.debug("Removing WebSocket Server session: " + session); } webSocketSessionRepository.removeChannel(channel); try { eventPublisher.publishEvent(new WebSocketSessionClosedEvent(session)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Error publishing WebSocket closed event: " + e.getMessage(), e); } } super.handlerRemoved(ctx); }
eventPublisher.publishEvent(new WebSocketSessionOpenEvent(session)); } catch (Exception e) { if (LOG.isErrorEnabled()) {
@Override public void publishEvent(Object event) { this.eventPublisher.publishEvent(event); } }
@Override public void publishEvent(ApplicationEvent event) { eventPublisher.publishEvent(event); }
@Override public void publishEvent(Object event) { eventPublisher.publishEvent(event); } }
@Override public void publishEvent(Object event) { this.eventPublisher.publishEvent(event); } }
@Override public void publishEvent(ApplicationEvent event) { this.eventPublisher.publishEvent(event); }
@Override public void publishEvent(ApplicationEvent event) { this.eventPublisher.publishEvent(event); }
@Override public void onApplicationEvent(Object event) { if (event instanceof StartupEvent) { eventPublisher.publishEvent(new ContextStartedEvent( applicationContext )); } else if (event instanceof ShutdownEvent) { eventPublisher.publishEvent(new ContextClosedEvent( applicationContext )); } } }
/** * Resets the circuit state to {@link CircuitState#CLOSED}. * * @return The current state */ private CircuitState closeCircuit() { if (LOG.isDebugEnabled()) { LOG.debug("Closing Circuit Breaker [{}]", method); } time = System.currentTimeMillis(); lastError = null; this.childState = (MutableRetryState) retryStateBuilder.build(); try { return state.getAndSet(CircuitState.CLOSED); } finally { if (eventPublisher != null) { try { eventPublisher.publishEvent(new CircuitClosedEvent(method)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Error publishing CircuitClosedEvent: " + e.getMessage(), e); } } } } }
/** * Opens the circuit. * * @return The current state */ private CircuitState openCircuit(Throwable cause) { if (cause == null) { throw new IllegalArgumentException("Exception cause cannot be null"); } if (LOG.isDebugEnabled()) { LOG.debug("Opening Circuit Breaker [{}] due to error: {}", method, cause.getMessage()); } this.childState = (MutableRetryState) retryStateBuilder.build(); this.lastError = cause; this.time = System.currentTimeMillis(); try { return state.getAndSet(CircuitState.OPEN); } finally { if (eventPublisher != null) { try { eventPublisher.publishEvent(new CircuitOpenEvent(method, childState, cause)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Error publishing CircuitOpen event: " + e.getMessage(), e); } } } } }
/** * Refresh application state only if environment has changed (unless <code>force</code> is set to true). * * @param force {@link Nullable} body property to indicate whether to force all {@link io.micronaut.runtime.context.scope.Refreshable} beans to be refreshed * @return array of change keys if applicable */ @Write public String[] refresh(@Nullable Boolean force) { if (force != null && force) { eventPublisher.publishEvent(new RefreshEvent()); return new String[0]; } else { Map<String, Object> changes = environment.refreshAndDiff(); if (!changes.isEmpty()) { eventPublisher.publishEvent(new RefreshEvent(changes)); } Set<String> keys = changes.keySet(); return keys.toArray(new String[keys.size()]); } } }
/** * Refresh application state only if environment has changed (unless <code>force</code> is set to true). * * @param force {@link Nullable} body property to indicate whether to force all {@link io.micronaut.runtime.context.scope.Refreshable} beans to be refreshed * @return array of change keys if applicable */ @Write public String[] refresh(@Nullable Boolean force) { if (force != null && force) { eventPublisher.publishEvent(new RefreshEvent()); return new String[0]; } else { Map<String, Object> changes = environment.refreshAndDiff(); if (!changes.isEmpty()) { eventPublisher.publishEvent(new RefreshEvent(changes)); } Set<String> keys = changes.keySet(); return keys.toArray(new String[keys.size()]); } } }
/** * Publish the heartbeat event with current health status. */ @Scheduled(fixedDelay = "${micronaut.heartbeat.interval:15s}", initialDelay = "${micronaut.heartbeat.initial-delay:5s}") public void pulsate() { ServiceInstance instance = eventReference.get(); if (instance != null) { eventPublisher.publishEvent(new HeartbeatEvent(instance, currentHealthStatus.current())); } }
if (eventPublisher != null) { try { eventPublisher.publishEvent(new RetryEvent(context, retryState, exception)); } catch (Exception e1) { LOG.error("Error occurred publishing RetryEvent: " + e1.getMessage(), e1);
if (eventPublisher != null) { try { eventPublisher.publishEvent(new RetryEvent(context, retryState, e)); } catch (Exception e1) { LOG.error("Error occurred publishing RetryEvent: " + e1.getMessage(), e1);