protected <T> Handler<Message<T>> convertHandler(Handler<AsyncResult<Message<T>>> handler) { return reply -> { Future<Message<T>> result; if (reply.body() instanceof ReplyException) { // This is kind of clunky - but hey-ho ReplyException exception = (ReplyException) reply.body(); if (metrics != null) { metrics.replyFailure(reply.address(), exception.failureType()); } result = Future.failedFuture(exception); } else { result = Future.succeededFuture(reply); } handler.handle(result); }; }
log.error("Failed to handleMessage. address: " + message.address(), e); if (metrics != null) { metrics.endHandleMessage(metric, e);
@Test public void testMessageBodyInterceptor() throws Exception { String content = TestUtils.randomUnicodeString(13); startNodes(2); waitFor(2); CountDownLatch latch = new CountDownLatch(1); vertices[0].eventBus().registerCodec(new StringLengthCodec()).<Integer>consumer("whatever", msg -> { assertEquals(content.length(), (int) msg.body()); complete(); }).completionHandler(ar -> latch.countDown()); awaitLatch(latch); StringLengthCodec codec = new StringLengthCodec(); vertices[1].eventBus().registerCodec(codec).addOutboundInterceptor(sc -> { if ("whatever".equals(sc.message().address())) { assertEquals(content, sc.body()); complete(); } sc.next(); }).send("whatever", content, new DeliveryOptions().setCodecName(codec.name())); await(); } }
protected <T> Handler<Message<T>> convertHandler(Handler<AsyncResult<Message<T>>> handler) { return reply -> { Future<Message<T>> result; if (reply.body() instanceof ReplyException) { // This is kind of clunky - but hey-ho ReplyException exception = (ReplyException) reply.body(); if (metrics != null) { metrics.replyFailure(reply.address(), exception.failureType()); } result = Future.failedFuture(exception); } else { result = Future.succeededFuture(reply); } handler.handle(result); }; }
/** * The address the message was sent to * @return */ public String address() { String ret = delegate.address(); return ret; }
/** * The address the message was sent to * @return */ public String address() { String ret = delegate.address(); return ret; }
@Override public String getAddress() { return message.address(); }
@Override public String getAddress() { return message.address(); }
log.error("Failed to handleMessage. address: " + message.address(), e); if (metrics != null) { metrics.endHandleMessage(metric, e);
@Override public void handle(Message<MessageStatus> event) { statusMessage = event.body(); _logger.debug("Event received: [address:{}, body:{}]", event.address(), event.body()); }
@Test public void testMessageBodyInterceptor() throws Exception { String content = TestUtils.randomUnicodeString(13); startNodes(2); waitFor(2); CountDownLatch latch = new CountDownLatch(1); vertices[0].eventBus().registerCodec(new StringLengthCodec()).<Integer>consumer("whatever", msg -> { assertEquals(content.length(), (int) msg.body()); complete(); }).completionHandler(ar -> latch.countDown()); awaitLatch(latch); StringLengthCodec codec = new StringLengthCodec(); vertices[1].eventBus().registerCodec(codec).addOutboundInterceptor(sc -> { if ("whatever".equals(sc.message().address())) { assertEquals(content, sc.body()); complete(); } sc.next(); }).send("whatever", content, new DeliveryOptions().setCodecName(codec.name())); await(); } }
@Override public void handle(Message<MessageStatus> event) { statusMessage = event.body(); _logger.debug("Event received: [address:{}, body:{}]", event.address(), event.body()); }
/** * Register the event handler which can be used to invalidate the LRU cache. */ public static void registerEventHandler() { Mesh.vertx().eventBus().consumer(EVENT_CLEAR_PERMISSION_STORE, e -> { if (log.isDebugEnabled()) { log.debug("Clearing permission store due to received event from {" + e.address() + "}"); } PERM_CACHE.invalidateAll(); }); }
.add(Frame.DESTINATION, msg.address()); if (!"auto".equals(subscription.ackMode)) {
sendFrame("message", res1.address(), res1.replyAddress(), responseHeaders, res1.isSend(), res1.body(), socket); })); } else {
sendFrame("message", res1.address(), res1.replyAddress(), responseHeaders, res1.isSend(), res1.body(), socket); })); } else {
final JsonObject body = event.body(); if (null == body) { log.warn("Got msg with empty body from event bus. We'll run directly in a NullPointerException now. address={} replyAddress={} ", event.address(), event.replyAddress()); final String queue = event.body(); if (queue == null) { log.warn("Got event bus msg with empty body! _28904718b4af0cc_ uid={} address={} replyAddress={}", uid, event.address(), event.replyAddress());
context.assertEquals(replyContent, reply.result().body().getValue(AmqpConstants.BODY), "unexpected reply msg content"); context.assertNotNull(reply.result().address(), "address was not set on reply"); context.assertNull(reply.result().replyAddress(), "reply address was unexpectedly set on the reply");
context.assertEquals(replyContent, replyMessage.body().getValue(AmqpConstants.BODY), "unexpected reply msg content"); context.assertNotNull(replyMessage.address(), "address was not set on the reply"); context.assertNotNull(replyMessage.replyAddress(), "reply address was not set on the reply");