congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CommandCallbackWrapper
Code IndexAdd Tabnine to your IDE (free)

How to use
CommandCallbackWrapper
in
org.axonframework.commandhandling.distributed

Best Java code snippets using org.axonframework.commandhandling.distributed.CommandCallbackWrapper (Showing top 14 results out of 315)

origin: AxonFramework/AxonFramework

/**
 * Removes all callbacks for a given channel. Registered callbacks will receive a failure response containing a
 * {@link CommandBusConnectorCommunicationException}.
 *
 * @param channelId the channel identifier
 */
public void cancelCallbacks(A channelId) {
  Iterator<CommandCallbackWrapper> callbacks = this.callbacks.values().iterator();
  while (callbacks.hasNext()) {
    CommandCallbackWrapper wrapper = callbacks.next();
    if (wrapper.getChannelIdentifier().equals(channelId)) {
      wrapper.reportResult(asCommandResultMessage(new CommandBusConnectorCommunicationException(
          String.format("Connection error while waiting for a response on command %s",
                 wrapper.getMessage().getCommandName()))));
      callbacks.remove();
    }
  }
}
origin: AxonFramework/AxonFramework

/**
 * Invokes {@link CommandCallback#onResult(CommandMessage, CommandResultMessage)} with given {@code result} on
 * the wrapped callback.
 *
 * @param result the result of the command
 */
public void reportResult(CommandResultMessage<R> result) {
  onResult(getMessage(), result);
}
origin: org.axonframework/axon-core

/**
 * Removes all callbacks for a given channel. Registered callbacks will receive a failure response containing a
 * {@link CommandBusConnectorCommunicationException}.
 *
 * @param channelId the channel identifier
 */
public void cancelCallbacks(A channelId) {
  Iterator<CommandCallbackWrapper> callbacks = this.callbacks.values().iterator();
  while (callbacks.hasNext()) {
    CommandCallbackWrapper wrapper = callbacks.next();
    if (wrapper.getChannelIdentifier().equals(channelId)) {
      wrapper.fail(new CommandBusConnectorCommunicationException(
          String.format("Connection error while waiting for a response on command %s",
                 wrapper.getMessage().getCommandName())));
      callbacks.remove();
    }
  }
}
origin: org.axonframework/axon-core

/**
 * Invokes {@link CommandCallback#onSuccess(CommandMessage, Object)} with given {@code result} on the wrapped
 * callback.
 *
 * @param result the result of the command
 */
public void success(R result) {
  onSuccess(getMessage(), result);
}
origin: org.axonframework/axon-core

/**
 * Invokes {@link CommandCallback#onFailure(CommandMessage, Throwable)} with given exception on the wrapped
 * callback.
 *
 * @param e cause for the failure
 */
public void fail(Throwable e) {
  onFailure(getMessage(), e);
}
origin: AxonFramework/AxonFramework

/**
 * Stores a callback
 *
 * @param callbackId             The id to store the callback with
 * @param commandCallbackWrapper The CommandCallbackWrapper to store
 * @param <E>                    The type of the remote endpoint identifier
 * @param <C>                    The type of the command
 * @param <R>                    The type of the result
 */
public <E, C, R> void store(String callbackId, CommandCallbackWrapper<E, C, R> commandCallbackWrapper) {
  CommandCallbackWrapper previous;
  if ((previous = callbacks.put(callbackId, commandCallbackWrapper)) != null) {
    //a previous callback with the same command ID was already found, we will cancel the callback as the command
    //is likely to be retried, so the previous one likely failed
    previous.reportResult(asCommandResultMessage(new CommandBusConnectorCommunicationException(
        "Command-callback cancelled, a new command with the same ID is entered into the command bus")));
  }
}
origin: org.axonframework/axon-distributed-commandbus-jgroups

private void processReplyMessage(JGroupsReplyMessage message) {
  CommandCallbackWrapper<Object, Object, Object> callbackWrapper =
      callbackRepository.fetchAndRemove(message.getCommandIdentifier());
  if (callbackWrapper == null) {
    logger.warn(
        "Received a callback for a message that has either already received a callback, or which was not " +
            "sent through this node. Ignoring.");
  } else {
    if (message.isSuccess()) {
      callbackWrapper.success(message.getReturnValue(serializer));
    } else {
      Throwable exception = getOrDefault(message.getError(serializer), new IllegalStateException(
          format("Unknown execution failure for command [%s]", message.getCommandIdentifier())));
      callbackWrapper.fail(exception);
    }
  }
}
origin: org.axonframework/axon-distributed-commandbus-jgroups

@Override
public <C, R> void send(Member destination, CommandMessage<C> command,
            CommandCallback<? super C, R> callback) throws Exception {
  callbackRepository.store(command.getIdentifier(), new CommandCallbackWrapper<>(destination, command, callback));
  channel.send(resolveAddress(destination), new JGroupsDispatchMessage(command, serializer, true));
}
origin: org.axonframework/axon-core

/**
 * Stores a callback
 *
 * @param callbackId             The id to store the callback with
 * @param commandCallbackWrapper The CommandCallbackWrapper to store
 * @param <E>                    The type of the remote endpoint identifier
 * @param <C>                    The type of the command
 * @param <R>                    The type of the result
 */
public <E, C, R> void store(String callbackId, CommandCallbackWrapper<E, C, R> commandCallbackWrapper) {
  CommandCallbackWrapper previous;
  if ((previous = callbacks.put(callbackId, commandCallbackWrapper)) != null) {
    //a previous callback with the same command ID was already found, we will cancel the callback as the command
    //is likely to be retried, so the previous one likely failed
    previous.fail(new CommandBusConnectorCommunicationException(
        "Command-callback cancelled, a new command with the same ID is entered into the command bus"));
  }
}
origin: org.axonframework/axon-messaging

/**
 * Stores a callback
 *
 * @param callbackId             The id to store the callback with
 * @param commandCallbackWrapper The CommandCallbackWrapper to store
 * @param <E>                    The type of the remote endpoint identifier
 * @param <C>                    The type of the command
 * @param <R>                    The type of the result
 */
public <E, C, R> void store(String callbackId, CommandCallbackWrapper<E, C, R> commandCallbackWrapper) {
  CommandCallbackWrapper previous;
  if ((previous = callbacks.put(callbackId, commandCallbackWrapper)) != null) {
    //a previous callback with the same command ID was already found, we will cancel the callback as the command
    //is likely to be retried, so the previous one likely failed
    previous.reportResult(asCommandResultMessage(new CommandBusConnectorCommunicationException(
        "Command-callback cancelled, a new command with the same ID is entered into the command bus")));
  }
}
origin: org.axonframework.extensions.jgroups/axon-jgroups

@Override
public <C, R> void send(Member destination,
            CommandMessage<C> command,
            CommandCallback<? super C, R> callback) throws Exception {
  callbackRepository.store(command.getIdentifier(), new CommandCallbackWrapper<>(destination, command, callback));
  channel.send(resolveAddress(destination), new JGroupsDispatchMessage(command, serializer, true));
}
origin: org.axonframework/axon-messaging

/**
 * Removes all callbacks for a given channel. Registered callbacks will receive a failure response containing a
 * {@link CommandBusConnectorCommunicationException}.
 *
 * @param channelId the channel identifier
 */
public void cancelCallbacks(A channelId) {
  Iterator<CommandCallbackWrapper> callbacks = this.callbacks.values().iterator();
  while (callbacks.hasNext()) {
    CommandCallbackWrapper wrapper = callbacks.next();
    if (wrapper.getChannelIdentifier().equals(channelId)) {
      wrapper.reportResult(asCommandResultMessage(new CommandBusConnectorCommunicationException(
          String.format("Connection error while waiting for a response on command %s",
                 wrapper.getMessage().getCommandName()))));
      callbacks.remove();
    }
  }
}
origin: org.axonframework/axon-messaging

/**
 * Invokes {@link CommandCallback#onResult(CommandMessage, CommandResultMessage)} with given {@code result} on
 * the wrapped callback.
 *
 * @param result the result of the command
 */
public void reportResult(CommandResultMessage<R> result) {
  onResult(getMessage(), result);
}
origin: org.axonframework.extensions.jgroups/axon-jgroups

private void processReplyMessage(JGroupsReplyMessage message) {
  CommandCallbackWrapper callbackWrapper = callbackRepository.fetchAndRemove(message.getCommandIdentifier());
  if (callbackWrapper == null) {
    logger.warn("Received a callback for a message that has either already received a callback, "
              + "or which was not sent through this node. Ignoring.");
  } else {
    //noinspection unchecked
    callbackWrapper.reportResult(message.getCommandResultMessage(serializer));
  }
}
org.axonframework.commandhandling.distributedCommandCallbackWrapper

Javadoc

Wrapper for a Command callback. This is used in a CommandCallbackRepository

Most used methods

  • <init>
    Initializes a CommandCallbackWrapper which wraps the original callback and holds on to the command m
  • fail
    Invokes CommandCallback#onFailure(CommandMessage,Throwable) with given exception on the wrapped call
  • getChannelIdentifier
    Returns the identifier of the channel over which the command message was sent.
  • getMessage
    Returns the command message that was sent.
  • reportResult
    Invokes CommandCallback#onResult(CommandMessage,CommandResultMessage) with given result on the wrapp
  • onFailure
  • onResult
  • onSuccess
  • success
    Invokes CommandCallback#onSuccess(CommandMessage,Object) with given result on the wrapped callback.

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JTable (javax.swing)
  • Top 12 Jupyter Notebook extensions
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