-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io.vertx.core.http.HttpClient.postAbs or requestAbs methods are removed in Vertx 4.X.X. Which methods we should use now and how? #72
Comments
@pendula95 Do you know this? |
There was a lot of cleaning work for HttpClient. Most of the methods were removed for simplicity of API changes-in-http-client If you want to have a http client for application business I would recommend using WebClient instead of HttpClient. As stated in migration guide: Vert.x web client
Vert.x HTTP client
It is possible to get same behavior as before so here are examples: httpClient.request(HttpMethod.POST, 80, "enw5gif6c6lhk.x.pipedream.net", "/test", handler1 -> {
if (handler1.succeeded()) {
handler1.result().send(handler2 -> {
if (handler2.succeeded()) {
System.out.println(handler2.result().statusCode());
//System.out.println(handler2.result().body().succeeded());
} else {
handler2.cause().printStackTrace();
}
});
} else {
handler1.cause().printStackTrace();
}
}); I would recommend using the Futures API as it is much cleaner: httpClient.request(HttpMethod.POST, 80, "enw5gif6c6lhk.x.pipedream.net", "/test")
.compose(HttpClientRequest::send)
.onFailure(Throwable::printStackTrace)
.onSuccess(response -> System.out.println(response.statusCode())); Also here is an example using WebClient which has postAbs: webClient.postAbs("http://enw5gif6c6lhk.x.pipedream.net/test")
.send()
.onFailure(Throwable::printStackTrace)
.onSuccess(response -> System.out.println(response.statusCode())); You are not the only one who asked this question so it might be a good idea to make a contribution to migration guide, so if you are up for it please take a shoot, especially if you are going to use this as you will get experience from first hand. |
@pendula95 Thanks your quick reply. I appreciate it. |
@pendula95 How can we migrate I could see, io.vertx.core.http.HttpClient.requestAbs overloaded methods has been moved to WebClient API. Not sure if I am pointing out correct. Can we use requestAbs method from Webclient? |
you can use |
@vietj Thanks. Let me check. Can you share its example? |
HttpClient httpClient = vertx.createHttpClient();
httpClient.request(new RequestOptions().setAbsoluteURI("https://enpc7phb98di.x.pipedream.net")
.setTimeout(3000))
.compose(HttpClientRequest::send)
.onFailure(Throwable::printStackTrace)
.onSuccess(response -> System.out.println(response.statusCode())); |
Thanks @pendula95 |
Questions
io.vertx.core.http.HttpClient.postAbs or requestAbs methods are removed in Vertx 4.X.X. Which methods we should use now and how?
Version
4.3.2
Context
Migrating Vertx 3.9.7 to 4.3.2
Do you have a reproducer?
Yes
Steps to reproduce
NA
Extra
JVM 17 - Amazon Corrento
The text was updated successfully, but these errors were encountered: