private Object readResolve() { return new org.axonframework.messaging.GenericMessage<>(identifier, payload, metaData.getValues()); } }
/** * 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(); } }
/** * 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(); } }
private Object readResolve() { return new org.axonframework.eventhandling.GenericEventMessage<>(getIdentifier(), getPayload(), MetaData.from(getMetaData().getValues()), Instant.ofEpochMilli(timestamp.getMillis())); } }