public function dispatch(CommandMessageInterface $command, CommandCallbackInterface $callback = null)
 {
     $this->dispatchedCommands[] = $command;
     try {
         if (null !== $callback) {
             $callback->onSuccess($this->callbackBehavior->handle($command->getPayload(), $command->getMetaData()));
         }
     } catch (\Exception $ex) {
         if (null !== $callback) {
             $callback->onFailure($ex);
         }
     }
 }
 public function provideAuditDataFor(CommandMessageInterface $command)
 {
     return $command->getMetaData()->all();
 }
 /**
  * @param CommandMessageInterface $command
  * @return null|string
  */
 protected function doResolveRoutingKey(CommandMessageInterface $command)
 {
     $value = $command->getMetaData()->get($this->metaDataKey);
     return isset($value) ? (string) $value : null;
 }