Codota Logo
ExecutionResult.getExceptionResult
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
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

  • Parsing JSON documents to java classes using gson
  • onRequestPermissionsResult (Fragment)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • setContentView (Activity)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • Kernel (java.awt.image)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now