io.vertx.serviceproxy.ServiceException Java Examples

The following examples show how to use io.vertx.serviceproxy.ServiceException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CounterServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #2
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-kubernetes-workshop with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #3
Source File: QueryableVertxProxyHandler.java    From vertx-graphql-service-discovery with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #4
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-kubernetes-workshop with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #5
Source File: EchoServiceVertxProxyHandler.java    From weld-vertx with Apache License 2.0 6 votes vote down vote up
public EchoServiceVertxProxyHandler(Vertx vertx, EchoService service, boolean topLevel, long timeoutSeconds) {
  this.vertx = vertx;
  this.service = service;
  this.timeoutSeconds = timeoutSeconds;
  try {
    this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
        new ServiceExceptionMessageCodec());
  } catch (IllegalStateException ex) {}
  if (timeoutSeconds != -1 && !topLevel) {
    long period = timeoutSeconds * 1000 / 2;
    if (period > 10000) {
      period = 10000;
    }
    this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
  } else {
    this.timerID = -1;
  }
  accessed();
}
 
Example #6
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-microservices-workshop with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #7
Source File: ShoppingCartServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #8
Source File: CheckoutServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
public CheckoutServiceVertxProxyHandler(Vertx vertx, CheckoutService service, boolean topLevel, long timeoutSeconds) {
  this.vertx = vertx;
  this.service = service;
  this.timeoutSeconds = timeoutSeconds;
  try {
    this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
        new ServiceExceptionMessageCodec());
  } catch (IllegalStateException ex) {}
  if (timeoutSeconds != -1 && !topLevel) {
    long period = timeoutSeconds * 1000 / 2;
    if (period > 10000) {
      period = 10000;
    }
    this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
  } else {
    this.timerID = -1;
  }
  accessed();
}
 
Example #9
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-microservices-workshop with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #10
Source File: EchoServiceVertxProxyHandler.java    From weld-vertx with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #11
Source File: AccountServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
public AccountServiceVertxProxyHandler(Vertx vertx, AccountService service, boolean topLevel, long timeoutSeconds) {
  this.vertx = vertx;
  this.service = service;
  this.timeoutSeconds = timeoutSeconds;
  try {
    this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
        new ServiceExceptionMessageCodec());
  } catch (IllegalStateException ex) {}
  if (timeoutSeconds != -1 && !topLevel) {
    long period = timeoutSeconds * 1000 / 2;
    if (period > 10000) {
      period = 10000;
    }
    this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
  } else {
    this.timerID = -1;
  }
  accessed();
}
 
Example #12
Source File: AccountServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #13
Source File: PaymentQueryServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
public PaymentQueryServiceVertxProxyHandler(Vertx vertx, PaymentQueryService service, boolean topLevel, long timeoutSeconds) {
  this.vertx = vertx;
  this.service = service;
  this.timeoutSeconds = timeoutSeconds;
  try {
    this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
        new ServiceExceptionMessageCodec());
  } catch (IllegalStateException ex) {}
  if (timeoutSeconds != -1 && !topLevel) {
    long period = timeoutSeconds * 1000 / 2;
    if (period > 10000) {
      period = 10000;
    }
    this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
  } else {
    this.timerID = -1;
  }
  accessed();
}
 
Example #14
Source File: CounterServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #15
Source File: CounterServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #16
Source File: CheckoutServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #17
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-microservices-workshop with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #18
Source File: EchoServiceVertxProxyHandler.java    From weld-vertx with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #19
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-microservices-workshop with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #20
Source File: OrderServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #21
Source File: PortfolioServiceVertxProxyHandler.java    From vertx-microservices-workshop with Apache License 2.0 6 votes vote down vote up
public PortfolioServiceVertxProxyHandler(Vertx vertx, PortfolioService service, boolean topLevel, long timeoutSeconds) {
  this.vertx = vertx;
  this.service = service;
  this.timeoutSeconds = timeoutSeconds;
  try {
    this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
        new ServiceExceptionMessageCodec());
  } catch (IllegalStateException ex) {}
  if (timeoutSeconds != -1 && !topLevel) {
    long period = timeoutSeconds * 1000 / 2;
    if (period > 10000) {
      period = 10000;
    }
    this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
  } else {
    this.timerID = -1;
  }
  accessed();
}
 
Example #22
Source File: OrderServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #23
Source File: OrderServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #24
Source File: ProductServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
public ProductServiceVertxProxyHandler(Vertx vertx, ProductService service, boolean topLevel, long timeoutSeconds) {
  this.vertx = vertx;
  this.service = service;
  this.timeoutSeconds = timeoutSeconds;
  try {
    this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
        new ServiceExceptionMessageCodec());
  } catch (IllegalStateException ex) {}
  if (timeoutSeconds != -1 && !topLevel) {
    long period = timeoutSeconds * 1000 / 2;
    if (period > 10000) {
      period = 10000;
    }
    this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
  } else {
    this.timerID = -1;
  }
  accessed();
}
 
Example #25
Source File: QueryableVertxProxyHandler.java    From vertx-graphql-service-discovery with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #26
Source File: ProductServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #27
Source File: ProductServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #28
Source File: AccountServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
Example #29
Source File: StoreCRUDServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private <T> Handler<AsyncResult<T>> createHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      if (res.result() != null  && res.result().getClass().isEnum()) {
        msg.reply(((Enum) res.result()).name());
      } else {
        msg.reply(res.result());
      }
    }
  };
}
 
Example #30
Source File: StoreCRUDServiceVertxProxyHandler.java    From vertx-blueprint-microservice with Apache License 2.0 6 votes vote down vote up
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}