Java Code Examples for reactor.bus.Event#getHeaders()
The following examples show how to use
reactor.bus.Event#getHeaders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventBusConfig.java From cloudbreak with Apache License 2.0 | 6 votes |
private String getFlowIdFromHeaders(Throwable throwable) { try { if (throwable.getCause() instanceof Exceptions.ValueCause) { if (((Exceptions.ValueCause) throwable.getCause()).getValue() instanceof Event) { Event event = (Event) ((Exceptions.ValueCause) throwable.getCause()).getValue(); LOGGER.info("Failed event: {}", event); Event.Headers headers = event.getHeaders(); if (headers != null) { LOGGER.info("Failed event headers: {}", headers); if (headers.get("FLOW_ID") != null) { return headers.get("FLOW_ID").toString(); } } else { LOGGER.info("Headers is null object for the event {}", event); } } } } catch (Exception e) { LOGGER.error("Something wrong happened when we tried to get flowId from headers", e); } return null; }
Example 2
Source File: CleanupFreeIpaHandler.java From cloudbreak with Apache License 2.0 | 6 votes |
@Override public void accept(Event<CleanupFreeIpaEvent> cleanupFreeIpaEvent) { CleanupFreeIpaEvent event = cleanupFreeIpaEvent.getData(); try { LOGGER.debug("Handle cleanup request for hosts: {} and IPs: {}", event.getHostNames(), event.getIps()); Stack stack = stackService.get(event.getResourceId()); freeIpaCleanupService.cleanup(stack, true, event.isRecover(), event.getHostNames(), event.getIps()); LOGGER.debug("Cleanup finished for hosts: {} and IPs: {}", event.getHostNames(), event.getIps()); } catch (Exception e) { LOGGER.error("FreeIPA cleanup failed for hosts {} and IPs: {}", event.getHostNames(), event.getIps(), e); } finally { CleanupFreeIpaEvent response = new CleanupFreeIpaEvent(CLEANUP_FREEIPA_FINISHED_EVENT.event(), event.getResourceId(), event.getHostNames(), event.getIps(), event.isRecover()); Event<StackEvent> responseEvent = new Event<>(cleanupFreeIpaEvent.getHeaders(), response); eventBus.notify(CLEANUP_FREEIPA_FINISHED_EVENT.event(), responseEvent); } }
Example 3
Source File: PublicKeyCreationHandler.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public void accept(Event<EnvironmentDto> environmentDtoEvent) { LOGGER.debug("Accepting PublicKeyCreation event"); EnvironmentDto environmentDto = environmentDtoEvent.getData(); try { environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(environment -> { if (environment.getAuthentication().isManagedKey()) { boolean created = environmentResourceService.createAndUpdateSshKey(environment); if (created) { String publicKeyId = environment.getAuthentication().getPublicKeyId(); LOGGER.info("Update the environment and it's authentication with the created public SSH key id: '{}'", publicKeyId); environmentService.save(environment); } else { LOGGER.info("The public key id could not be created for {}", environmentDto.getName()); } } else { LOGGER.debug("Environment {} requested no managed public key", environment.getName()); } }); EnvCreationEvent envCreationEvent = getEnvCreateEvent(environmentDto); eventSender().sendEvent(envCreationEvent, environmentDtoEvent.getHeaders()); } catch (Exception e) { EnvCreationFailureEvent failedEvent = new EnvCreationFailureEvent(environmentDto.getId(), environmentDto.getName(), e, environmentDto.getResourceCrn()); Event<EnvCreationFailureEvent> ev = new Event<>(environmentDtoEvent.getHeaders(), failedEvent); eventBus.notify(failedEvent.selector(), ev); } }