• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Feed aggregator using Vert.x 3 (showcase)

Feed aggregator using Vert.x 3 and Vertx-web.

StackShare Travis

This project is designed to show what a real-life application can look like with Vert.x.

It's a simple feed agregator.

Every user can subscribe to some feeds (RSS, ...), then Vert.x will periodically read these feeds and store news (and notify connected clients).

Users and their subscriptions user are store in MongoDB. Feed entries (RSS news article for example) are stored in Redis.

How it works :

Simple use-case :

  • Users register using a simple login / password. An User is a simple document in MongoDB database. (there's no need for an email address in this demo)
  • Once they're registered, they can subscribe to feeds by providing the feed's URL (and a color, for UI display). A Feed is another document in MongoDB.
  • Subscriptions are stored in user infos (user.subscriptions) but also in a plain mongo collection listing feeds and the number of people who subscribed to this feed.
  • Periodically, a verticle lists the entries in the feeds collection and for each of the feeds that have a subscriber count > 0, will read the RSS feed and fetch new entries
  • New feed entries are store into JSON objects in a Redis set. The key is the feed's URL hash, the value is the JSON equivalent of the RSS entry and the score is the timestamp of the entry's publication date
  • When a user asks for his news feed entries, they are aggregated from Redis for each of his subscriptions
  • When the new feed entries are stored into Redis, they're also pushed as a List of entries on Vertx's event bus. This allows end users who are connected from client side to receive real-time updates by subscribing directly to event bus notifications.

Feed API :

  • GET /api/feeds : lists user's subscriptions
  • POST /api/feeds : subscribe to a new feed
  • GET /api/feeds/:feedId : fetches information for a specific feed
  • PUT /api/feeds/:feedId : update infos for a specific feed (color especially)
  • DELETE /api/feeds/:feedId : unsubscribe to a feed
  • GET /api/feeds/:feedId/entries : fetches the feed entries

Schema :

                 +--------------------------+                                                   
                 |                          |                                                   
                 |  Verticle (= broker)     |                                                   
                 |                          |                                                   
                 |                          |                                                   
                 |                          |                                                   
                 |fetch items / subscription|                                                   
                 | +-------------------+    |                                                   
                 | |                   |    |                                                   
                 +--------------------------+                                                   
list subscriptions |                   | populate items in Redis                                
 +-----------------+----------+ +------+--------------------+                                   
 |                            | |                           |                                   
 |          MongoDB           | |           Redis           |                                   
 |                            | |                           |                                   
 |                            | |                           |                                   
 | Stores :                   | | Stores :                  |                                   
 | - Users                    | | - Items per feed          |                                   
 | - Their subscriptions      | |                           |                                   
 | - A collection of feeds    | |                           |                                   
 |                            | |                           |                                   
 +-----------------^----------+ +----^----------------------+                                   
 login / create user / subscribe     | poll periodically for each connected user -> push updates
                +---------------------------------+                                             
                |  Web verticle (API + Sockets)   |                                             
                |                                 |                                             
                | - serves pages                  |                                             
                | | login users                   |                                             
                | | serves items through API      |                                             
                | - real-time updates (sockjs)    |                                             
                |                                 |                                             
                |                                 |                                             
                |                                 |                                             
                +---------------------------------+                                             

What it illustrates

The goal of this project is to be informative for every user who wants to see what Vert.x is able to do.

You'll find :

  • how to build dynamic server-side rendered pages thanks to Handlebars and it's implementation in Vert.x (HandlebarsTemplateEngine)
  • how to build a JSON REST API using vertx-web's Router
  • how to read data from a JSON REST API using AngularJS on client-side
  • how to read / write from / to MongoDB in an asynchronous way thanks to vertx-mongo-client
  • how to use vertx-redis-client to store items in a redis set asynchronously
  • a very simple implementation of the publish / subscribe pattern on Vert.x's event bus, one of its key features.
  • how to expose Vert.x's event bus messages on client-side thanks to Vert.x EventBusBridge using sockjs
  • examples of code involving Java 8 lambdas to deal with an asynchronous API
  • some (hopefully) useful classes to deal with asynchronous stuff, like the MultipleFutures class
  • how to package a whole Vert.x application (fatJar) using Gradle, see build.gradle

For now, the project is here for you to read its code, not at all for production use.

If you want to run it on your local machine, from the root of the project, type in ./gradlew run from the command-line. If you want to run it from your IDE, you have to create a "Run configuration" involving io.vertx.core.Starter as main-class with the following arguments : run io.vertx.examples.feeds.verticles.MainVerticle. This way you can easily debug the source code.

Then you can point your browser at : http://localhost:9000/index.hbs and you should see the home page.

Redis and Mongo are embedded in the application so that you don't need to install them locally.

Contributing

The project is completely free. You can fork the project, use it for your own purpose if you want to.

Feel free to open issues, or ask questions on Vert.x Google Group if you have any.

Feel free to highlight source code that you don't understand or would have written in a different way, I'd be happy to discuss and even more happy if you're right and point me at a more elegant way to write the application's source code.

Obviously, you can submit a Pull Request if you're pretty sure something would be better if written differently, or that a key feature of Vert.x is missing and you'd like it to be illustrated in this example (but keep in mind this project should be kept simple, it's already a bit complicated to dive in).

Thanks anyway for any kind of contribution you could submit, it's greatly appreciated. :)

More Repositories

1

nubes

Annotation layer on top of Vert.x 3
Java
120
star
2

vertx-sse

Add support for Server-Sent-Events in Vert.x Web
Java
47
star
3

vertx-hibernate-service

Hibernate service for Vert.x
Java
19
star
4

grooveex

Extension module for vertx-groovy adding methods and syntaxic sugar
Groovy
14
star
5

vertx-eventbus-client-rs

Rust client for Vert.x TCP event-bus bridge
Rust
10
star
6

vertx-load-balancer

Example on how to write a very simple load balancer using Vert.x
Java
9
star
7

quarkus-scala-gradle

Simple project showing Quarkus working with Scala and Gradle
Kotlin
9
star
8

nashorn-es6

Test to make nashorn compatible with Ecma 6
JavaScript
7
star
9

vertx-kotlin-todomvc

Implementation of the TodoMVC server using Vert.x and Kotlin
Kotlin
7
star
10

http2-showcase

Showcase for http2 Vert.x server vs. standard http
Java
7
star
11

w3rs

Warcraft 3 (Reforged) replay parser, written in Rust
Rust
6
star
12

vertx-markdown-service

Basic Vert.x service to generate html from markdown over the event bus
Java
6
star
13

todo-backend-vertx

Java
5
star
14

fertx

Functional Vert.x Web + Scala (inspired by Akka http)
Scala
4
star
15

vertx-service-registry

Website to show Vert.x 3 available services
Java
4
star
16

vertx-pojo-config

Simple Vert.x extension to map your JsonObject configuration to a standard Java bean
Java
3
star
17

nubes-chat

Example of a chat application built with Nubes framework
JavaScript
3
star
18

projuice

The juicy project manager
Java
2
star
19

connect-fs-source-demo

Very simple demo playing with the filsystem source connector
Dockerfile
2
star
20

quarkus-kotlin-todobackend

Trying to implement todobackend in Kotlin with Quarkus
Kotlin
2
star
21

buska

Search & Find records in Apache Kafka
Rust
2
star
22

vertx-calliope

Add more expressiveness to vertx-web
Java
2
star
23

vertx-web-groovy-dsl

A simple Groovy DSL to declare Vert.x Apex routes
Groovy
2
star
24

vertx-react-isomorphic

Attempt to make an isomorphic React application with vertx-lang-js
JavaScript
2
star
25

todobackend-springboot2

TodoBackend implementation using SpringBoot 2 + reactive mongo + kotlin
Kotlin
2
star
26

todobackend-phoenix

TodoBackend implementation using Phoenix + PostgreSQL
Elixir
1
star
27

kafka-streams-rename-topics-scala

Show how to use a single Kafka Streams app to rename a set of input topics
Scala
1
star
28

reactive-pg-client-pipelining

Trying to reproduce an issue with pipelining
Kotlin
1
star
29

nubes-orm

ORM utilities for Nubes
Java
1
star
30

vertx-scala-todomvc

TodoMVC implementation using Vert.x-lang-scala
Scala
1
star
31

vertx-ceylon-todobackend

TodoBackend implementation in Ceylon using Vert.x
Ceylon
1
star
32

vertx-portal

Everything you need to know about Vert.x
Groovy
1
star
33

nubes-mongo

Mongo implementation of nubes-orm
Java
1
star
34

vertx-mvc-specifications

Specification wiki for a MVC-layer on top of Vert.x 3 stack
1
star
35

rapidoid-todobackend-hibernate

TodoBackend implementation using Rapidoid & JPA (Hibernate)
Java
1
star
36

todo-backend-grooveex

TodoMVC backend using grooveex on top of Vert.x 3
Groovy
1
star
37

quarkus-smallrye-jwt-reproducer

Reproducer showing buildNative fail with smallrye jwt
Kotlin
1
star
38

swapi-finch

Experiment : a gateway using finagle / finch (based on swapi.co)
Scala
1
star
39

vertx-groovy-template-engine

Vertx template engine adapter for Groovy TemplateEngine
Java
1
star
40

itinerarium

PROTOTYPE of a Rust API gateway system - for learning purposes only -
Rust
1
star
41

ceylon-react

simple test
Ceylon
1
star
42

nubes-hibernate

Hibernate utilities (service, interceptors, ...) for Nubes
Java
1
star
43

vertx-dgraph-client

Small example showing how to use vertx-grpc client in order to target a running dgraph service
Java
1
star
44

vertx-git-service

Asynchronous, polyglot service to deal with Git repositories
Java
1
star