{"id":23483766,"url":"https://github.com/codesmell/vertx-bookmarks","last_synced_at":"2025-12-31T14:32:33.003Z","repository":{"id":108722798,"uuid":"42597342","full_name":"CodeSmell/VertX-Bookmarks","owner":"CodeSmell","description":"Building the Bookmarks REST services in Vert.x based on chapter 1 of Seven Web Frameworks in Seven Weeks","archived":false,"fork":false,"pushed_at":"2015-10-08T22:26:50.000Z","size":184,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T02:15:50.754Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeSmell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-16T15:52:57.000Z","updated_at":"2018-11-29T11:26:38.000Z","dependencies_parsed_at":"2023-03-05T18:57:36.206Z","dependency_job_id":null,"html_url":"https://github.com/CodeSmell/VertX-Bookmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CodeSmell/VertX-Bookmarks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FVertX-Bookmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FVertX-Bookmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FVertX-Bookmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FVertX-Bookmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeSmell","download_url":"https://codeload.github.com/CodeSmell/VertX-Bookmarks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FVertX-Bookmarks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265837605,"owners_count":23836558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-24T21:16:10.252Z","updated_at":"2025-12-31T14:32:32.973Z","avatar_url":"https://github.com/CodeSmell.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VertX-Bookmarks\nThis project was created as a place to learn ([Vert.x](http://vertx.io/)), an event driven and non blocking framework for creating reactive applications. Vert.x runs on the JVM and its architecture and approach are based on the Reactor pattern, similar to Node.js.\n\nIf you are wondering about Vert.x, there is an interview with creator Tim Fox on ([InfoQ](http://www.infoq.com/articles/vertx-3-tim-fox)). There is also a good writeup in ([JavaWorld](http://www.javaworld.com/article/2078838/mobile-java/open-source-java-projects-vert-x.html)), though it covers version 2.\n\nThis version is built using Java 8 and Maven, but Vert.x can support various JVM languages\n\nThe ([Reactive Manifesto](http://www.reactivemanifesto.org/)) defines reactive applications as \"systems that are Responsive, Resilient, Elastic and Message Driven.\"\n\nThis project builds the Bookmarks REST services found in chapter 1 of the Pragmatic Programmers book *Seven Web Frameworks in Seven Weeks*. The original services in the book were built using Sinatra and Ruby. \n\nIt also relied on the Vert.x Core Manual and the Intro series\n- ([Core Manual](http://vertx.io/docs/vertx-core/java/))\n- ([My First Vert.x app] (http://vertx.io/blog/my-first-vert-x-3-application/index.html))\n- ([Vert.x App Configuration] (http://vertx.io/blog/vert-x-application-configuration/index.html))\n- ([Some REST with Vert.x] (http://vertx.io/blog/some-rest-with-vert-x/index.html))\n- ([Unit and Integration tests] (http://vertx.io/blog/unit-and-integration-tests/index.html))\n\n## Handling Objects\nOne challenge when I started working on the project was how to manage dependencies. After working with IoC frameworks, it seemed like a step backward to start doing this:\n\n\tprivate BookmarkDao bookmarksDao = new BookmarkNoDatabaseDao();\n\t\nTherefore I chose to use Spring IoC to manage dependencies but that is not required for Vert.x applications. \n\n## Handling Data Access\nThe other challenge in this project was working through how to access data. While using MongoDB is recommended, I figured that the original Bookmarks project in the PragProg book used a RDBMS. And, let's face it most projects are using SQL databases. Having already chosen to manage dependencies with Spring, I chose to use MyBatis and Spring to handle the data access.\n\n## The User Interface and Verticles\nI thought it would be helpful to add a simple Web UI for the bookmarks. I was originally trying to do this with two Verticles. One Verticle would handle the REST API and the other Verticle would serve the static resources. \n\n\tpublic class BookmarksVerticle {\n\t\t...\n\t\tpublic void start(Future\u003cVoid\u003e future) {\n\t\t\t...\n\t\t\t\n\t\t\trouter.get(BOOKMARK_URL).handler(this::getAllBookmarks);\n\t\t\t\n\t\t\t...\n\t\t\t\n\t\t\tvertx.createHttpServer().requestHandler(router::accept).listen(8080, ...\n\nand \n\n\tpublic class BookmarksStaticWebVerticle {\n\t\t...\n\t\tpublic void start(Future\u003cVoid\u003e future) {\n\t\t\t...\n\t\t\t\n\t\t\trouter.route(BOOKMARK_URL + \"/static/*\").handler(StaticHandler.create());\n\t\t\t\n\t\t\t...\n\t\t\t\n\t\t\tvertx.createHttpServer().requestHandler(router::accept).listen(8080, ...\n\n\nBut when I deployed them both I got \n\n\tSEVERE: Address already in use: bind\n\tjava.net.BindException: Address already in use: bind\n\nI found out that I can't do that unless I started the HTTP listener on a different port. \n\nThe other option was to create a third Verticle to listen for HTTP requests, parse them based on the path and send the requests to the REST Verticle and Static Web Verticle over the over the event bus. My original two Verticles would then listen for these requests over the event bus instead of HTTP. \n\nThis might make for a good refactor later. \n\n## Running from Maven\nRun the following goals: \n\t\n\tmvn clean package\n\nThen run the \"fat\" JAR file\n\t\n\tjava -jar target/Bookmarks-0.0.1-SNAPSHOT-fat.jar\n\n## Testing Bookmarks\nOnce the application is running you can test the REST API using various tools (SOAP UI, curl etc). \nThe easiest way is to use a browser and access one of the REST API that uses the GET method \n\t\t\n\thttp://localhost:8080/bookmarks\n\nThis should return a JSON array:\n\n\t[ {\n\t  \"bookmarkId\" : \"1\",\n\t  \"bookmarkUrl\" : \"http://vertx.io\",\n\t  \"bookmarkTitle\" : \"Vert.x Reactive Framework\"\n\t}, {\n\t  \"bookmarkId\" : \"2\",\n\t  \"bookmarkUrl\" : \"http://typesafe.com/\",\n\t  \"bookmarkTitle\" : \"Typesafe Reactive Framework\"\n\t} ]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesmell%2Fvertx-bookmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodesmell%2Fvertx-bookmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesmell%2Fvertx-bookmarks/lists"}