use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class Rescheduler method onScheduledCommandExpired.
/**
* Sets the status of the expired command to error.
*
* <p>We cannot post such a command because there is no handler or dispatcher registered yet.
* Or, posting such a command may be undesirable from the business logic point of view.
*
* @param command the expired command
* @see CommandExpiredException
*/
private void onScheduledCommandExpired(Command command) {
final CommandEnvelope commandEnvelope = CommandEnvelope.of(command);
final Message msg = commandEnvelope.getMessage();
final CommandId id = commandEnvelope.getId();
final Error error = CommandExpiredException.commandExpired(command);
commandStore().setToError(commandEnvelope, error);
log().errorExpiredCommand(msg, id);
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class Records method newRecordBuilder.
/**
* Creates a command storage record builder passed on the passed parameters.
*
* <p>{@code targetId} and {@code targetIdType} are set to empty strings if
* the command is not for an entity.
*
* @param command a command to convert to a record. This includes instances of faulty
* commands. An example of such a fault is missing command ID.
* @param status a command status to set in the record
* @param generatedCommandId a command ID to be used because the passed command does not have
* own ID. If the command has own ID, this parameter is {@code null}.
* @return a storage record
*/
static CommandRecord.Builder newRecordBuilder(Command command, CommandStatus status, @Nullable CommandId generatedCommandId) {
final CommandId commandId = generatedCommandId != null ? generatedCommandId : command.getId();
final String commandType = CommandEnvelope.of(command).getTypeName().getSimpleName();
final CommandRecord.Builder builder = CommandRecord.newBuilder().setCommandId(commandId).setCommandType(commandType).setCommand(command).setTimestamp(getCurrentTime()).setStatus(ProcessingStatus.newBuilder().setCode(status));
return builder;
}
Aggregations