• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReplyFailure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.vertx.core.eventbus.ReplyFailure的典型用法代码示例。如果您正苦于以下问题:Java ReplyFailure类的具体用法?Java ReplyFailure怎么用?Java ReplyFailure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReplyFailure类属于io.vertx.core.eventbus包,在下文中一共展示了ReplyFailure类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: send

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
protected void send(Request request, String target) {
    DeliveryOptions options = new DeliveryOptions().setSendTimeout(request.timeout());

    core.bus().send(target, request.data(), options, send -> {
        if (send.succeeded()) {
            request.write(send.result().body());
        } else {
            Throwable exception = send.cause();

            if (exception instanceof ReplyException) {
                ReplyFailure status = ((ReplyException) exception).failureType();
                exceptionHandlers.get(status).accept(request);
            } else {
                request.error(send.cause());
            }
        }
    });
}
 
开发者ID:codingchili,项目名称:chili-core,代码行数:19,代码来源:BusRouter.java


示例2: replyJson

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
private static JsonObject replyJson(ReplyException ex) {
  JsonObject jsonObject = new JsonObject();
  DefaultErrorCode errorCode = DefaultErrorCode.getCode(ex.failureCode());
  if (errorCode != null) {
    jsonObject.put("code", errorCode.getNumber())
            .put("message", errorCode.getMessage());
  } else {
    ReplyFailure replyFailure = ex.failureType();
    if (replyFailure == ReplyFailure.NO_HANDLERS) {
      jsonObject.put("code", DefaultErrorCode.SERVICE_UNAVAILABLE.getNumber())
              .put("message", DefaultErrorCode.SERVICE_UNAVAILABLE.getMessage());
    } else if (replyFailure == ReplyFailure.TIMEOUT) {
      jsonObject.put("code", DefaultErrorCode.TIME_OUT.getNumber())
              .put("message", DefaultErrorCode.TIME_OUT.getMessage());
    } else if (replyFailure == ReplyFailure.RECIPIENT_FAILURE) {
      jsonObject.put("code", ex.failureCode())
              .put("message", ex.getMessage());
    } else {
      jsonObject.put("code", DefaultErrorCode.UNKOWN.getNumber())
              .put("message", DefaultErrorCode.UNKOWN.getMessage());
    }
  }
  return jsonObject;
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:25,代码来源:FailureHandler.java


示例3: failed

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
private void failed(Future<RpcResponse> completed,
                    Throwable throwable) {
  if (throwable instanceof ReplyException) {
    ReplyException ex = (ReplyException) throwable;
    if (ex.failureType() == ReplyFailure.NO_HANDLERS) {
      SystemException resourceNotFoundEx =
              SystemException.create(DefaultErrorCode.SERVICE_UNAVAILABLE)
                      .set("details", "No handlers");
      completed.fail(resourceNotFoundEx);
    } else {
      ErrorCode errorCode = CustomErrorCode.create(ex.failureCode(), ex.getMessage(), 400);
      SystemException systemException
              = SystemException.create(errorCode);
      completed.fail(systemException);
    }
  } else {
    completed.fail(throwable);
  }
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:20,代码来源:EventbusRpcHandler.java


示例4: testCallWithMessageParamWrongType

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testCallWithMessageParamWrongType() {
  JsonObject message = new JsonObject();
  message.put("object", new JsonObject().put("foo", "bar"));
  message.put("str", 76523);
  message.put("i", 1234);
  message.put("char", (int)'X'); // chars are mapped to ints
  message.put("enum", SomeEnum.BAR.toString()); // enums are mapped to strings
  vertx.eventBus().send("someaddress", message, new DeliveryOptions().addHeader("action", "invokeWithMessage").setSendTimeout(500), onFailure(t -> {
    assertTrue(t instanceof ReplyException);
    ReplyException re = (ReplyException) t;
    // This will as operation will fail to be invoked
    assertEquals(ReplyFailure.RECIPIENT_FAILURE, re.failureType());
    testComplete();
  }));
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:18,代码来源:ServiceProxyTest.java


示例5: replyFailure

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Override
public void replyFailure(String address, ReplyFailure failure) {
    switch (failure) {
        case TIMEOUT:
            counterService.increment("reply.failures.timeout");
            break;
        case NO_HANDLERS:
            counterService.increment("reply.failures.noHandlers");
            break;
        case RECIPIENT_FAILURE:
            counterService.increment("reply.failures.recipientFailure");
            break;
    }
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:15,代码来源:VertxActuatorMetrics.java


示例6: shutdownHandler

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
/**
 *  Use to terminate the application using a HTTP Post
 *  It requires an AdminKey header to work
 */
private void shutdownHandler(final RoutingContext ctx) {
	// check for AdminKey header
	String adminKey = this.config().getString("AdminKey");
	if (adminKey == null || adminKey.equals(ctx.request().getHeader("AdminKey"))) {
		// TODO: check the body for the right credentials
		this.shutdownExecution(ctx.response());
	} else {
		ctx.fail(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, 401, "Sucker nice try!"));
	}
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:15,代码来源:ApplicationStarter.java


示例7: createServer

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Before
public void createServer(TestContext testContext) {
  vertx = Vertx.vertx();
  Router router = Router.router(vertx);
  router.route().handler(BodyHandler.create());
  router.route().handler(BaseHandler.create());
  router.get("/ex/sys").handler(rc -> {
    throw SystemException.create(DefaultErrorCode.MISSING_ARGS);
  });
  router.get("/ex/validate").handler(rc -> {
    Multimap<String, String> error = ArrayListMultimap.create();
    throw new ValidationException(error);
  });
  router.get("/ex/unkown").handler(rc -> {
    throw new RuntimeException("xxxx");
  });
  router.get("/ex/reply").handler(rc -> {
    throw new ReplyException(ReplyFailure.TIMEOUT, DefaultErrorCode.INVALID_REQ.getNumber(),
                             DefaultErrorCode.INVALID_REQ.getMessage());
  });

  router.get("/ex/reply2").handler(rc -> {
    throw new ReplyException(ReplyFailure.RECIPIENT_FAILURE);
  });
  router.route().failureHandler(FailureHandler.create());
  vertx.createHttpServer().requestHandler(router::accept)
          .listen(port, testContext.asyncAssertSuccess());
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:29,代码来源:FailureHandlerTest.java


示例8: consumerSendTimeout

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
public void consumerSendTimeout(@Observes @VertxConsumer(TEST_BUS_TIMEOUT) VertxEvent event) {
    assertEquals(TEST_BUS_TIMEOUT, event.getAddress());
    event.messageTo(TEST_SLOW_HANDLER).setDeliveryOptions(new DeliveryOptions().setSendTimeout(10)).send("foo", (r) -> {
        if (r.failed()) {
            ReplyException exception = (ReplyException) r.cause();
            if (exception.failureType().equals(ReplyFailure.TIMEOUT)) {
                SYNCHRONIZER.add("timeout");
            }
        }
    });
}
 
开发者ID:weld,项目名称:weld-vertx,代码行数:12,代码来源:VertxObservers.java


示例9: testThrowableToCodeReplyException

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
/**
 * Test code of {@link ReplyException}
 */
@Test
public void testThrowableToCodeReplyException() {
  int expectedCode = 505;
  
  Throwable throwable = new ReplyException(ReplyFailure.NO_HANDLERS, expectedCode, "Message");
  
  int statusCode = ThrowableHelper.throwableToCode(throwable);
  assertEquals(expectedCode, statusCode);
}
 
开发者ID:georocket,项目名称:georocket,代码行数:13,代码来源:ThrowableHelperTest.java


示例10: replyFailure

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Override
public void replyFailure(String address, ReplyFailure failure) {
  Map<String, String> labels = new HashMap<>();
  labels.putAll(defaultLabels);
  labels.put(SENSISION_CLASS_EB_LABEL_ADDRESS, address);
  incrementMetric(SENSISION_CLASS_EB_MESSAGE_REPLY_ERROR_COUNT, labels);
}
 
开发者ID:slambour,项目名称:vertx-warp10-metrics,代码行数:8,代码来源:EventBusMetricsImpl.java


示例11: testEventBusMetricsReplyNoHandlers

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testEventBusMetricsReplyNoHandlers() {
  vertx.eventBus().send("foo", "bar", new DeliveryOptions().setSendTimeout(300), ar -> {
    assertTrue(ar.failed());
    testComplete();
  });

  await();

  JsonObject metrics = metricsService.getMetricsSnapshot(vertx.eventBus());
  assertCount(metrics.getJsonObject("messages.reply-failures"), 1L);
  assertCount(metrics.getJsonObject("messages.reply-failures." + ReplyFailure.NO_HANDLERS), 1L);
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:14,代码来源:MetricsTest.java


示例12: testEventBusMetricsReplyTimeout

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testEventBusMetricsReplyTimeout() {
  vertx.eventBus().consumer("foo").handler(msg -> {});

  vertx.eventBus().send("foo", "bar", new DeliveryOptions().setSendTimeout(300), ar -> {
    assertTrue(ar.failed());
    testComplete();
  });

  await();

  JsonObject metrics = metricsService.getMetricsSnapshot(vertx.eventBus());
  assertCount(metrics.getJsonObject("messages.reply-failures"), 1L);
  assertCount(metrics.getJsonObject("messages.reply-failures." + ReplyFailure.TIMEOUT), 1L);
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:16,代码来源:MetricsTest.java


示例13: testEventBusMetricsReplyRecipientFailure

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testEventBusMetricsReplyRecipientFailure() {
  vertx.eventBus().consumer("foo").handler(msg -> msg.fail(1, "blah"));

  vertx.eventBus().send("foo", "bar", new DeliveryOptions(), ar -> {
    assertTrue(ar.failed());
    testComplete();
  });

  await();

  JsonObject metrics = metricsService.getMetricsSnapshot(vertx.eventBus());
  assertCount(metrics.getJsonObject("messages.reply-failures"), 1L);
  assertCount(metrics.getJsonObject("messages.reply-failures." + ReplyFailure.RECIPIENT_FAILURE), 1L);
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:16,代码来源:MetricsTest.java


示例14: testFailingMethod

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testFailingMethod() {
  proxy.failingMethod(onFailure(t -> {
    assertTrue(t instanceof ReplyException);
    ReplyException re = (ReplyException) t;
    assertEquals(ReplyFailure.RECIPIENT_FAILURE, re.failureType());
    assertEquals("wibble", re.getMessage());
    testComplete();
  }));
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:12,代码来源:ServiceProxyTest.java


示例15: testCallWithMessageInvalidAction

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testCallWithMessageInvalidAction() {
  JsonObject message = new JsonObject();
  message.put("object", new JsonObject().put("foo", "bar"));
  message.put("str", "blah");
  message.put("i", 1234);
  vertx.eventBus().send("someaddress", message, new DeliveryOptions().addHeader("action", "yourmum").setSendTimeout(500), onFailure(t -> {
    assertTrue(t instanceof ReplyException);
    ReplyException re = (ReplyException) t;
    // This will as operation will fail to be invoked
    assertEquals(ReplyFailure.RECIPIENT_FAILURE, re.failureType());
    testComplete();
  }));
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:16,代码来源:ServiceProxyTest.java


示例16: testConnectionTimeout

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testConnectionTimeout() {

  consumer.unregister();
  long timeoutSeconds = 2;
  consumer = ProxyHelper.registerService(TestService.class, vertx, service, SERVICE_ADDRESS, timeoutSeconds);

  proxy.createConnection("foo", onSuccess(conn -> {
    long start = System.nanoTime();

    conn.startTransaction(onSuccess(res -> {
      assertEquals("foo", res);

      vertx.eventBus().consumer("closeCalled").handler(msg -> {
        assertEquals("blah", msg.body());

        long duration = System.nanoTime() - start;
        assertTrue(String.valueOf(duration), duration >= SECONDS.toNanos(timeoutSeconds));

        // Should be closed now
        conn.startTransaction(onFailure(cause -> {
          assertNotNull(cause);
          assertTrue(cause instanceof ReplyException);
          assertFalse(cause instanceof ServiceException);
          ReplyException re = (ReplyException) cause;
          assertEquals(ReplyFailure.NO_HANDLERS, re.failureType());
          testComplete();
        }));


      });

    }));
  }));

  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:38,代码来源:ServiceProxyTest.java


示例17: testConnectionWithCloseFutureTimeout

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testConnectionWithCloseFutureTimeout() {

  consumer.unregister();
  long timeoutSeconds = 2;
  consumer = ProxyHelper.registerService(TestService.class, vertx, service, SERVICE_ADDRESS, timeoutSeconds);

  long start = System.currentTimeMillis();
  proxy.createConnectionWithCloseFuture(onSuccess(conn -> {

    vertx.eventBus().consumer("closeCalled").handler(msg -> {
      assertEquals("blah", msg.body());

      long now = System.currentTimeMillis();
      assertTrue(now - start > timeoutSeconds * 1000);

      // Should be closed now
      conn.someMethod(onFailure(cause -> {
        assertNotNull(cause);
        assertTrue(cause instanceof ReplyException);
        assertFalse(cause instanceof ServiceException);
        ReplyException re = (ReplyException) cause;
        assertEquals(ReplyFailure.NO_HANDLERS, re.failureType());
        testComplete();
      }));
    });
  }));

  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:31,代码来源:ServiceProxyTest.java


示例18: testLongDelivery2

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Test
public void testLongDelivery2() {
  TestService proxyLong = TestService.createProxyLongDelivery(vertx, SERVICE_ADDRESS);
  proxyLong.longDeliveryFailed(onFailure(t -> {
    assertNotNull(t);
    assertTrue(t instanceof ReplyException);
    assertFalse(t instanceof ServiceException);
    ReplyException re = (ReplyException) t;
    assertEquals(ReplyFailure.TIMEOUT, re.failureType());
    testComplete();
  }));
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:14,代码来源:ServiceProxyTest.java


示例19: replyFailure

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Override
public void replyFailure(String address, ReplyFailure failure) {
    dispatch(m -> m.replyFailure(address, failure));
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:5,代码来源:DispatchingEventBusMetrics.java


示例20: replyFailure

import io.vertx.core.eventbus.ReplyFailure; //导入依赖的package包/类
@Override
public void replyFailure(@NotNull String address, @NotNull ReplyFailure failure) {
  failures.labels(AddressResolver.instance.apply(address), "reply", failure.name()).inc();
}
 
开发者ID:nolequen,项目名称:vertx-prometheus-metrics,代码行数:5,代码来源:EventBusPrometheusMetrics.java



注:本文中的io.vertx.core.eventbus.ReplyFailure类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFBundleAddMsg类代码示例发布时间:2022-05-22
下一篇:
Java PlatformListFakeActivity类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap