Search in sources :

Example 1 with MessageClass

use of io.spine.type.MessageClass in project core-java by SpineEventEngine.

the class CommandHandler method onError.

@Override
public void onError(CommandEnvelope envelope, RuntimeException exception) {
    checkNotNull(envelope);
    checkNotNull(exception);
    final MessageClass messageClass = envelope.getMessageClass();
    final String messageId = Stringifiers.toString(envelope.getId());
    final String errorMessage = format("Error handling command (class: %s id: %s).", messageClass, messageId);
    log().error(errorMessage, exception);
}
Also used : MessageClass(io.spine.type.MessageClass)

Example 2 with MessageClass

use of io.spine.type.MessageClass in project core-java by SpineEventEngine.

the class ExternalEventSubscriber method onError.

@Override
public void onError(ExternalMessageEnvelope envelope, RuntimeException exception) {
    checkNotNull(envelope);
    checkNotNull(exception);
    final MessageClass messageClass = envelope.getMessageClass();
    final String messageId = Stringifiers.toString(envelope.getId());
    final String errorMessage = format("Error handling external event subscription (class: %s id: %s).", messageClass, messageId);
    log().error(errorMessage, exception);
}
Also used : MessageClass(io.spine.type.MessageClass)

Example 3 with MessageClass

use of io.spine.type.MessageClass in project core-java by SpineEventEngine.

the class DelegatingRejectionDispatcher method getExternalDispatcher.

/**
 * Wraps this dispatcher to an external rejection dispatcher.
 *
 * @return the external rejection dispatcher proxying calls to the underlying instance
 */
public ExternalMessageDispatcher<I> getExternalDispatcher() {
    return new ExternalMessageDispatcher<I>() {

        @Override
        public Set<ExternalMessageClass> getMessageClasses() {
            final Set<RejectionClass> rejectionClasses = delegate.getExternalRejectionClasses();
            return ExternalMessageClass.fromRejectionClasses(rejectionClasses);
        }

        @Override
        public Set<I> dispatch(ExternalMessageEnvelope envelope) {
            final ExternalMessage externalMessage = envelope.getOuterObject();
            final Rejection rejection = unpack(externalMessage.getOriginalMessage());
            final Set<I> ids = delegate.dispatchRejection(RejectionEnvelope.of(rejection));
            return ids;
        }

        @Override
        public void onError(ExternalMessageEnvelope envelope, RuntimeException exception) {
            final MessageClass messageClass = envelope.getMessageClass();
            final String messageId = Stringifiers.toString(envelope.getId());
            final String errorMessage = format("Error dispatching external rejection (class: %s, id: %s)", messageClass, messageId);
            log().error(errorMessage, exception);
        }
    };
}
Also used : Rejection(io.spine.core.Rejection) ExternalMessageClass(io.spine.server.integration.ExternalMessageClass) ExternalMessageClass(io.spine.server.integration.ExternalMessageClass) MessageClass(io.spine.type.MessageClass) ExternalMessageEnvelope(io.spine.server.integration.ExternalMessageEnvelope) ExternalMessageDispatcher(io.spine.server.integration.ExternalMessageDispatcher) RejectionClass(io.spine.core.RejectionClass) ExternalMessage(io.spine.server.integration.ExternalMessage)

Example 4 with MessageClass

use of io.spine.type.MessageClass in project core-java by SpineEventEngine.

the class RejectionSubscriber method onError.

/**
 * Logs the error into the subscriber {@linkplain #log() log}.
 *
 * @param envelope  the message which caused the error
 * @param exception the error
 */
@Override
public void onError(RejectionEnvelope envelope, RuntimeException exception) {
    checkNotNull(envelope);
    checkNotNull(exception);
    final MessageClass messageClass = envelope.getMessageClass();
    final String messageId = Stringifiers.toString(envelope.getId());
    final String errorMessage = format("Rejection subscriber (%s) could not handle rejection (class: %s id: %s).", this, messageClass, messageId);
    log().error(errorMessage, exception);
}
Also used : MessageClass(io.spine.type.MessageClass)

Example 5 with MessageClass

use of io.spine.type.MessageClass in project core-java by SpineEventEngine.

the class Repository method logError.

/**
 * Logs error caused by a message processing into the {@linkplain #log() repository log}.
 *
 * <p>The formatted message has the following parameters:
 * <ol>
 *     <li>The name of the message class.
 *     <li>The message ID.
 * </ol>
 *
 * @param msgFormat the format of the message
 * @param envelope  the envelope of the message caused the error
 * @param exception the error
 */
protected void logError(String msgFormat, MessageEnvelope envelope, RuntimeException exception) {
    final MessageClass messageClass = envelope.getMessageClass();
    final String messageId = Stringifiers.toString(envelope.getId());
    final String errorMessage = format(msgFormat, messageClass, messageId);
    log().error(errorMessage, exception);
}
Also used : MessageClass(io.spine.type.MessageClass)

Aggregations

MessageClass (io.spine.type.MessageClass)7 Rejection (io.spine.core.Rejection)1 RejectionClass (io.spine.core.RejectionClass)1 ExternalMessage (io.spine.server.integration.ExternalMessage)1 ExternalMessageClass (io.spine.server.integration.ExternalMessageClass)1 ExternalMessageDispatcher (io.spine.server.integration.ExternalMessageDispatcher)1 ExternalMessageEnvelope (io.spine.server.integration.ExternalMessageEnvelope)1