用其他方式拨打其他微服务

时间:2014-09-21 01:44:08

标签: asynchttpclient undertow

我有一个使用底部的简单websocket服务器。

如何在此方法中使用UndertowClient对其他微服务进行HTTP调用?

任何指针?

@OnMessage
public String onMessage(String message) {
    //Receive request -- make async micro call - Response will be sent later
    return "request received";
}

感谢

1 个答案:

答案 0 :(得分:0)

从这里采取: https://github.com/undertow-io/undertow/blob/master/websockets-jsr/src/test/java/io/undertow/websockets/jsr/test/JsrWebSocketServer07Test.java

import io.undertow.websockets.utils.WebSocketTestClient;
...
WebSocketTestClient client = new WebSocketTestClient(getVersion(), new URI("ws://" + NetworkUtils.formatPossibleIpv6Address(DefaultServer.getHostAddress("default")) + ":" + DefaultServer.getHostPort("default") + "/"));
    client.connect();
    client.send(new BinaryWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(BinaryWebSocketFrame.class, payload, latch));
    latch.getIoFuture().get();
    Assert.assertNull(cause.get());
    client.destroy();