Merge pull request #8125 from eugenp/revert-8119-BAEL-3275-2

Revert "BAEL-3275: Using blocking queue for pub-sub"
This commit is contained in:
Eric Martin
2019-10-31 20:43:47 -05:00
committed by GitHub
parent db85c8f275
commit 3225470df5
20543 changed files with 1642750 additions and 0 deletions
@@ -0,0 +1,28 @@
package com.baeldung;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
public class HelloVerticle extends AbstractVerticle {
private static final Logger LOGGER = LoggerFactory.getLogger(HelloVerticle.class);
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new HelloVerticle());
}
@Override
public void start(Future<Void> future) {
LOGGER.info("Welcome to Vertx");
}
@Override
public void stop() {
LOGGER.info("Shutting down application");
}
}
@@ -0,0 +1,24 @@
package com.baeldung;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
public class SimpleServerVerticle extends AbstractVerticle {
@Override
public void start(Future<Void> future) {
vertx.createHttpServer()
.requestHandler(
r -> r.response().end("Welcome to Vert.x Intro"))
.listen(config().getInteger("http.port", 8080), result -> {
if (result.succeeded()) {
future.complete();
} else {
future.fail(result.cause());
}
});
}
}
@@ -0,0 +1,59 @@
package com.baeldung.model;
public class Article {
private String id;
private String content;
private String author;
private String datePublished;
private int wordCount;
public Article(String id, String content, String author, String datePublished, int wordCount) {
super();
this.id = id;
this.content = content;
this.author = author;
this.datePublished = datePublished;
this.wordCount = wordCount;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getDatePublished() {
return datePublished;
}
public void setDatePublished(String datePublished) {
this.datePublished = datePublished;
}
public int getWordCount() {
return wordCount;
}
public void setWordCount(int wordCount) {
this.wordCount = wordCount;
}
}
@@ -0,0 +1,41 @@
package com.baeldung.rest;
import com.baeldung.model.Article;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.json.Json;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
public class RestServiceVerticle extends AbstractVerticle {
@Override
public void start(Future<Void> future) {
Router router = Router.router(vertx);
router.get("/api/baeldung/articles/article/:id")
.handler(this::getArticles);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(config().getInteger("http.port", 8080), result -> {
if (result.succeeded()) {
future.complete();
} else {
future.fail(result.cause());
}
});
}
private void getArticles(RoutingContext routingContext) {
String articleId = routingContext.request()
.getParam("id");
Article article = new Article(articleId, "This is an intro to vertx", "baeldung", "01-02-2017", 1578);
routingContext.response()
.putHeader("content-type", "application/json")
.setStatusCode(200)
.end(Json.encodePrettily(article));
}
}