Tabnine Logo
ExecutionResult.getExceptionResult
Code IndexAdd Tabnine to your IDE (free)

How to use
getExceptionResult
method
in
org.axonframework.messaging.unitofwork.ExecutionResult

Best Java code snippets using org.axonframework.messaging.unitofwork.ExecutionResult.getExceptionResult (Showing top 11 results out of 315)

origin: AxonFramework/AxonFramework

/**
 * Set the execution result of processing the current {@link #getMessage() Message}. In case this context has a
 * previously set ExecutionResult, setting a new result is only allowed if the new result is an exception result.
 * <p/>
 * In case the previously set result is also an exception result, the exception in the new execution result is
 * added to the original exception as a suppressed exception.
 *
 * @param executionResult the ExecutionResult of the currently handled Message
 */
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void setExecutionResult(ExecutionResult executionResult) {
  Assert.state(this.executionResult == null || executionResult.isExceptionResult(),
         () -> String.format("Cannot change execution result [%s] to [%s] for message [%s].",
          message, this.executionResult, executionResult));
  if (this.executionResult != null && this.executionResult.isExceptionResult()) {
    this.executionResult.getExceptionResult().addSuppressed(executionResult.getExceptionResult());
  } else {
    this.executionResult = executionResult;
  }
}
origin: AxonFramework/AxonFramework

  @Override
  public BiFunction<Integer, EventMessage<?>, EventMessage<?>> handle(List<? extends EventMessage<?>> messages) {
    StringBuilder sb = new StringBuilder(String.format("Events published: [%s]",
                              messages.stream().map(m -> m.getPayloadType().getSimpleName()).collect(Collectors.joining(", "))));
    CurrentUnitOfWork.ifStarted(unitOfWork -> {
      Message<?> message = unitOfWork.getMessage();
      if (message == null) {
        sb.append(" while processing an operation not tied to an incoming message");
      } else {
        sb.append(String.format(" while processing a [%s]", message.getPayloadType().getSimpleName()));
      }
      ExecutionResult executionResult = unitOfWork.getExecutionResult();
      if (executionResult != null) {
        if (executionResult.isExceptionResult()) {
          @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
          Throwable exception = executionResult.getExceptionResult();
          exception = exception instanceof ExecutionException ? exception.getCause() : exception;
          sb.append(String.format(" which failed with a [%s]", exception.getClass().getSimpleName()));
        } else if (executionResult.getResult() != null) {
          sb.append(String.format(" which yielded a [%s] return value",
                      executionResult.getResult().getClass().getSimpleName()));
        }
      }
    });
    logger.info(sb.toString());
    return (i, m) -> m;
  }
}
origin: AxonFramework/AxonFramework

@Override
public void publish(List<? extends EventMessage<?>> events) {
  Stream<MessageMonitor.MonitorCallback> ingested = events.stream().map(messageMonitor::onMessageIngested);
  if (CurrentUnitOfWork.isStarted()) {
    UnitOfWork<?> unitOfWork = CurrentUnitOfWork.get();
    Assert.state(!unitOfWork.phase().isAfter(PREPARE_COMMIT),
           () -> "It is not allowed to publish events when the current Unit of Work has already been " +
               "committed. Please start a new Unit of Work before publishing events.");
    Assert.state(!unitOfWork.root().phase().isAfter(PREPARE_COMMIT),
           () -> "It is not allowed to publish events when the root Unit of Work has already been " +
               "committed.");
    unitOfWork.afterCommit(u -> ingested.forEach(MessageMonitor.MonitorCallback::reportSuccess));
    unitOfWork.onRollback(uow -> ingested.forEach(
        message -> message.reportFailure(uow.getExecutionResult().getExceptionResult())
    ));
    eventsQueue(unitOfWork).addAll(events);
  } else {
    try {
      prepareCommit(intercept(events));
      commit(events);
      afterCommit(events);
      ingested.forEach(MessageMonitor.MonitorCallback::reportSuccess);
    } catch (Exception e) {
      ingested.forEach(m -> m.reportFailure(e));
      throw e;
    }
  }
}
origin: AxonFramework/AxonFramework

@Override
protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) {
  AppendEventTransaction sender;
  if (CurrentUnitOfWork.isStarted()) {
    sender = CurrentUnitOfWork.get().root().getOrComputeResource(APPEND_EVENT_TRANSACTION, k -> {
      AppendEventTransaction appendEventTransaction = eventStoreClient.createAppendEventConnection();
      CurrentUnitOfWork.get().root().onRollback(
          u -> appendEventTransaction.rollback(u.getExecutionResult().getExceptionResult())
      );
      CurrentUnitOfWork.get().root().onCommit(u -> commit(appendEventTransaction));
      return appendEventTransaction;
    });
  } else {
    sender = eventStoreClient.createAppendEventConnection();
  }
  for (EventMessage<?> eventMessage : events) {
    sender.append(map(eventMessage, serializer));
  }
  if (!CurrentUnitOfWork.isStarted()) {
    commit(sender);
  }
}
origin: org.axonframework/axon-messaging

/**
 * Set the execution result of processing the current {@link #getMessage() Message}. In case this context has a
 * previously set ExecutionResult, setting a new result is only allowed if the new result is an exception result.
 * <p/>
 * In case the previously set result is also an exception result, the exception in the new execution result is
 * added to the original exception as a suppressed exception.
 *
 * @param executionResult the ExecutionResult of the currently handled Message
 */
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void setExecutionResult(ExecutionResult executionResult) {
  Assert.state(this.executionResult == null || executionResult.isExceptionResult(),
         () -> String.format("Cannot change execution result [%s] to [%s] for message [%s].",
          message, this.executionResult, executionResult));
  if (this.executionResult != null && this.executionResult.isExceptionResult()) {
    this.executionResult.getExceptionResult().addSuppressed(executionResult.getExceptionResult());
  } else {
    this.executionResult = executionResult;
  }
}
origin: org.axonframework/axon-core

/**
 * Set the execution result of processing the current {@link #getMessage() Message}. In case this context has a
 * previously set ExecutionResult, setting a new result is only allowed if the new result is an exception result.
 * <p/>
 * In case the previously set result is also an exception result, the exception in the new execution result is
 * added to the original exception as a suppressed exception.
 *
 * @param executionResult the ExecutionResult of the currently handled Message
 */
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void setExecutionResult(ExecutionResult executionResult) {
  Assert.state(this.executionResult == null || executionResult.isExceptionResult(),
         () -> String.format("Cannot change execution result [%s] to [%s] for message [%s].",
          message, this.executionResult, executionResult));
  if (this.executionResult != null && this.executionResult.isExceptionResult()) {
    this.executionResult.getExceptionResult().addSuppressed(executionResult.getExceptionResult());
  } else {
    this.executionResult = executionResult;
  }
}
origin: org.axonframework/axon-messaging

  @Override
  public BiFunction<Integer, EventMessage<?>, EventMessage<?>> handle(List<? extends EventMessage<?>> messages) {
    StringBuilder sb = new StringBuilder(String.format("Events published: [%s]",
                              messages.stream().map(m -> m.getPayloadType().getSimpleName()).collect(Collectors.joining(", "))));
    CurrentUnitOfWork.ifStarted(unitOfWork -> {
      Message<?> message = unitOfWork.getMessage();
      if (message == null) {
        sb.append(" while processing an operation not tied to an incoming message");
      } else {
        sb.append(String.format(" while processing a [%s]", message.getPayloadType().getSimpleName()));
      }
      ExecutionResult executionResult = unitOfWork.getExecutionResult();
      if (executionResult != null) {
        if (executionResult.isExceptionResult()) {
          @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
          Throwable exception = executionResult.getExceptionResult();
          exception = exception instanceof ExecutionException ? exception.getCause() : exception;
          sb.append(String.format(" which failed with a [%s]", exception.getClass().getSimpleName()));
        } else if (executionResult.getResult() != null) {
          sb.append(String.format(" which yielded a [%s] return value",
                      executionResult.getResult().getClass().getSimpleName()));
        }
      }
    });
    logger.info(sb.toString());
    return (i, m) -> m;
  }
}
origin: org.axonframework/axon-core

  @Override
  public BiFunction<Integer, EventMessage<?>, EventMessage<?>> handle(List<? extends EventMessage<?>> messages) {
    StringBuilder sb = new StringBuilder(String.format("Events published: [%s]",
                              messages.stream().map(m -> m.getPayloadType().getSimpleName()).collect(Collectors.joining(", "))));
    CurrentUnitOfWork.ifStarted(unitOfWork -> {
      Message<?> message = unitOfWork.getMessage();
      if (message == null) {
        sb.append(" while processing an operation not tied to an incoming message");
      } else {
        sb.append(String.format(" while processing a [%s]", message.getPayloadType().getSimpleName()));
      }
      ExecutionResult executionResult = unitOfWork.getExecutionResult();
      if (executionResult != null) {
        if (executionResult.isExceptionResult()) {
          @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
          Throwable exception = executionResult.getExceptionResult();
          exception = exception instanceof ExecutionException ? exception.getCause() : exception;
          sb.append(String.format(" which failed with a [%s]", exception.getClass().getSimpleName()));
        } else if (executionResult.getResult() != null) {
          sb.append(String.format(" which yielded a [%s] return value",
                      executionResult.getResult().getClass().getSimpleName()));
        }
      }
    });
    logger.info(sb.toString());
    return (i, m) -> m;
  }
}
origin: org.axonframework/axon-core

@Override
public void publish(List<? extends EventMessage<?>> events) {
  Stream<MessageMonitor.MonitorCallback> ingested = events.stream().map(messageMonitor::onMessageIngested);
  if (CurrentUnitOfWork.isStarted()) {
    UnitOfWork<?> unitOfWork = CurrentUnitOfWork.get();
    Assert.state(!unitOfWork.phase().isAfter(PREPARE_COMMIT),
           () -> "It is not allowed to publish events when the current Unit of Work has already been " +
              "committed. Please start a new Unit of Work before publishing events.");
    Assert.state(!unitOfWork.root().phase().isAfter(PREPARE_COMMIT),
           () -> "It is not allowed to publish events when the root Unit of Work has already been " +
              "committed.");
    unitOfWork.afterCommit(u -> ingested.forEach(MessageMonitor.MonitorCallback::reportSuccess));
    unitOfWork.onRollback(u -> ingested.forEach(m -> m.reportFailure(u.getExecutionResult().getExceptionResult())));
    eventsQueue(unitOfWork).addAll(events);
  } else {
    try {
      prepareCommit(intercept(events));
      commit(events);
      afterCommit(events);
      ingested.forEach(MessageMonitor.MonitorCallback::reportSuccess);
    } catch (Exception e) {
      ingested.forEach(m -> m.reportFailure(e));
      throw e;
    }
  }
}
origin: org.axonframework/axon-messaging

@Override
public void publish(List<? extends EventMessage<?>> events) {
  Stream<MessageMonitor.MonitorCallback> ingested = events.stream().map(messageMonitor::onMessageIngested);
  if (CurrentUnitOfWork.isStarted()) {
    UnitOfWork<?> unitOfWork = CurrentUnitOfWork.get();
    Assert.state(!unitOfWork.phase().isAfter(PREPARE_COMMIT),
           () -> "It is not allowed to publish events when the current Unit of Work has already been " +
               "committed. Please start a new Unit of Work before publishing events.");
    Assert.state(!unitOfWork.root().phase().isAfter(PREPARE_COMMIT),
           () -> "It is not allowed to publish events when the root Unit of Work has already been " +
               "committed.");
    unitOfWork.afterCommit(u -> ingested.forEach(MessageMonitor.MonitorCallback::reportSuccess));
    unitOfWork.onRollback(uow -> ingested.forEach(
        message -> message.reportFailure(uow.getExecutionResult().getExceptionResult())
    ));
    eventsQueue(unitOfWork).addAll(events);
  } else {
    try {
      prepareCommit(intercept(events));
      commit(events);
      afterCommit(events);
      ingested.forEach(MessageMonitor.MonitorCallback::reportSuccess);
    } catch (Exception e) {
      ingested.forEach(m -> m.reportFailure(e));
      throw e;
    }
  }
}
origin: org.axonframework/axon-server-connector

@Override
protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) {
  AppendEventTransaction sender;
  if (CurrentUnitOfWork.isStarted()) {
    sender = CurrentUnitOfWork.get().root().getOrComputeResource(APPEND_EVENT_TRANSACTION, k -> {
      AppendEventTransaction appendEventTransaction = eventStoreClient.createAppendEventConnection();
      CurrentUnitOfWork.get().root().onRollback(
          u -> appendEventTransaction.rollback(u.getExecutionResult().getExceptionResult())
      );
      CurrentUnitOfWork.get().root().onCommit(u -> commit(appendEventTransaction));
      return appendEventTransaction;
    });
  } else {
    sender = eventStoreClient.createAppendEventConnection();
  }
  for (EventMessage<?> eventMessage : events) {
    sender.append(map(eventMessage, serializer));
  }
  if (!CurrentUnitOfWork.isStarted()) {
    commit(sender);
  }
}
org.axonframework.messaging.unitofworkExecutionResultgetExceptionResult

Javadoc

Get the execution result in case the result is an exception. If the execution yielded no exception this method returns null.

Popular methods of ExecutionResult

  • <init>
    Initializes an ExecutionResult from the given result.
  • getResult
    Return the execution result message.
  • isExceptionResult
    Check if the result of the execution yielded an exception.

Popular in Java

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now