private Object readResolve() { return new org.axonframework.eventhandling.GenericEventMessage<>(getIdentifier(), getPayload(), MetaData.from(getMetaData().getValues()), Instant.ofEpochMilli(timestamp.getMillis())); } }
private Object readResolve() { return new org.axonframework.messaging.GenericMessage<>(identifier, payload, metaData.getValues()); } }
public OrderId() { super(IdentifierFactory.getInstance().generateIdentifier()); } }
@Override public boolean onEvent(EventMessage<?> event) { if (event.getPayload() instanceof RequestStopTransactionAcceptedEvent) { RequestStopTransactionAcceptedEvent requestStopTransactionAcceptedEvent = (RequestStopTransactionAcceptedEvent) event.getPayload(); LOG.info("RequestStopTransactionAcceptedEvent successfully received " + requestStopTransactionAcceptedEvent); return true; } if (event.getPayload() instanceof RequestStopTransactionRejectedEvent) { RequestStopTransactionRejectedEvent requestStopTransactionRejectedEvent = (RequestStopTransactionRejectedEvent) event.getPayload(); LOG.info("RequestStopTransactionRejectedEvent successfully received " + requestStopTransactionRejectedEvent); return true; } return false; } };
/** * Creates a {@code CorrelationUnitOfWorkListener} which adds correlation meta data to registered events. * * @param command the command for which * @throws NullPointerException if {@code command} is {@code null}. * @throws IllegalArgumentException if {@code command} does not contain the {@code correlationToken} or if the * {@code correlationToken} is not a {@code CorrelationToken}. */ public CorrelationUnitOfWorkListener(CommandMessage<?> command) { checkNotNull(command); checkArgument(command.getMetaData().containsKey(CorrelationToken.KEY)); checkArgument(command.getMetaData().get(CorrelationToken.KEY) instanceof CorrelationToken); correlationToken = (CorrelationToken) command.getMetaData().get(CorrelationToken.KEY); }
@Override protected String doResolveRoutingKey(CommandMessage<?> command) { Object value = command.getMetaData().get(metaDataKey); return value == null ? null : value.toString(); } }
@Override protected AbstractDomainEvent<?> asDomainEvent(final Object event) { if(event instanceof GenericEventMessage) { // this seems to be the case on error final GenericEventMessage genericEventMessage = (GenericEventMessage) event; final Object payload = genericEventMessage.getPayload(); return asDomainEventIfPossible(payload); } // don't think this occurs with axon, but this is the original behaviour // before the above change to detect GenericEventMessage return asDomainEventIfPossible(event); }
/** * {@inheritDoc} */ @Override public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event) { return event.withMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } }
@Override public void post(final Object event) { simpleEventBus.publish(GenericEventMessage.asEventMessage(event)); }
/** * Handler method which registers a {@link CorrelationUnitOfWorkListener} if the given command contains the required * meta data to correlate this command to the resulting events. * * @throws Throwable no checked exceptions will be thrown. This is required to implement the {@code CommandHandlerInterceptor} interface. */ @Override public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable { CommandMessage<?> commandWithKeyAdded = null; if (!command.getMetaData().containsKey(CorrelationToken.KEY)) { commandWithKeyAdded = command.andMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); } UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(commandWithKeyAdded != null ? commandWithKeyAdded : command); unitOfWork.registerListener(listener); return chain.proceed(); } }
@Override public boolean onEvent(EventMessage<?> event) { if (event.getPayload() instanceof RequestStartTransactionAcceptedEvent) { RequestStartTransactionAcceptedEvent requestStartTransactionAcceptedEvent = (RequestStartTransactionAcceptedEvent) event.getPayload(); LOG.info("RequestStartTransactionAcceptedEvent successfully received " + requestStartTransactionAcceptedEvent); return true; } if (event.getPayload() instanceof RequestStartTransactionRejectedEvent) { RequestStartTransactionRejectedEvent requestStartTransactionRejectedEvent = (RequestStartTransactionRejectedEvent) event.getPayload(); LOG.info("RequestStartTransactionRejectedEvent successfully received " + requestStartTransactionRejectedEvent); return true; } return false; } };
public ExchangeId() { super(IdentifierFactory.getInstance().generateIdentifier()); }
@Override public String resolveRoutingKey(EventMessage eventMessage) { if (eventMessage.getPayload() instanceof CommunicationWithChargingStationRequestedEvent) { CommunicationWithChargingStationRequestedEvent event = (CommunicationWithChargingStationRequestedEvent) eventMessage.getPayload(); return ROUTING_KEY_PREFIX + event.getProtocol(); } else { return this.routingKeyResolver.resolveRoutingKey(eventMessage); } }
/** * Handles the {@code IncomingDataTransferResultEvent} and wraps the result in a {@code IncomingDataTransferResult} which is * written to the 'result' member. Returns true if the event is of type {@code IncomingDataTransferResultEvent}, otherwise * false. Does a countDown on the countDownLatch to indicate the 'wait' is over. * * @param event event message * @return true if the event is of type {@code IncomingDataTransferResultEvent}, otherwise false. */ @Override public boolean onEvent(EventMessage<?> event) { IncomingDataTransferResultEvent resultEvent; if (event.getPayload() instanceof IncomingDataTransferResultEvent) { resultEvent = (IncomingDataTransferResultEvent) event.getPayload(); this.setResult(new IncomingDataTransferResult(resultEvent.getData(), resultEvent.getStatus())); this.countDownLatch(); if (continuation != null) { // no need to wait for the continuation timeout, resume it now continuation.resume(); } return true; } else { // not the right type of event... not 'handled' return false; } }
@Override public boolean onEvent(EventMessage<?> event) { IncomingDataTransferResultEvent resultEvent; if (event.getPayload() instanceof AuthorizationResultEvent) { resultEvent = (IncomingDataTransferResultEvent) event.getPayload(); IncomingDataTransferResult result = new IncomingDataTransferResult(resultEvent.getData(), resultEvent.getStatus()); this.setResult(result); this.countDownLatch(); webSocketWrapper.sendResultMessage(new WampMessage(WampMessage.CALL_RESULT, callId, MessageProcUri.DATA_TRANSFER, result)); return true; } else { // not the right type of event... not 'handled' return false; } }
/** * Handles the {@code AuthorizationResultEvent} and wraps the result in a {@code AuthorizationResult} which is * written to the 'result' member. Returns true if the event is of type {@code AuthorizationResultEvent}, otherwise * false. Does a countDown on the countDownLatch to indicate the 'wait' is over. * * @param event event message * @return true if the event is of type {@code AuthorizationResultEvent}, otherwise false. */ @Override public boolean onEvent(EventMessage<?> event) { AuthorizationResultEvent resultEvent; if (event.getPayload() instanceof AuthorizationResultEvent) { resultEvent = (AuthorizationResultEvent) event.getPayload(); this.setResult(new AuthorizationResult(resultEvent.getIdentifyingToken().getToken(), resultEvent.getAuthenticationStatus())); this.countDownLatch(); if (continuation != null) { // no need to wait for the continuation timeout, resume it now continuation.resume(); } return true; } else { // not the right type of event... not 'handled' return false; } }
@Override public boolean onEvent(EventMessage<?> event) { AuthorizationResultEvent resultEvent; if (event.getPayload() instanceof AuthorizationResultEvent) { resultEvent = (AuthorizationResultEvent) event.getPayload(); AuthorizeResponse response = new AuthorizeResponse(); IdTagInfo idTagInfo = new IdTagInfo(); idTagInfo.setStatus(IdTagInfo.Status.fromValue(resultEvent.getAuthenticationStatus().value())); response.setIdTagInfo(idTagInfo); this.setResult(response); this.countDownLatch(); webSocketWrapper.sendResultMessage(new WampMessage(WampMessage.CALL_RESULT, callId, MessageProcUri.AUTHORIZE, response)); return true; } else { // not the right type of event... not 'handled' return false; } }
AuthorizationResultEvent resultEvent; if (!(event.getPayload() instanceof AuthorizationResultEvent)) { resultEvent = (AuthorizationResultEvent) event.getPayload();
AuthorizationResultEvent resultEvent; if (!(event.getPayload() instanceof AuthorizationResultEvent)) { resultEvent = (AuthorizationResultEvent) event.getPayload();