{"id":30671617,"url":"https://github.com/gregory-ledenev/easyroutingclustersample","last_synced_at":"2025-09-01T04:02:04.865Z","repository":{"id":312291339,"uuid":"1046582913","full_name":"gregory-ledenev/EasyRoutingClusterSample","owner":"gregory-ledenev","description":"This sample project and step-by-step tutorial demonstrates building a simple clustered application using EasyRouting for Vert.x.","archived":false,"fork":false,"pushed_at":"2025-08-29T15:12:17.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T18:32:10.763Z","etag":null,"topics":["cluster","java","microservices","sample","tutorial","vertx"],"latest_commit_sha":null,"homepage":"","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/gregory-ledenev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-28T22:51:28.000Z","updated_at":"2025-08-29T15:12:20.000Z","dependencies_parsed_at":"2025-08-29T18:32:28.907Z","dependency_job_id":"34cb208c-e2cd-4170-8d80-67b1d752d8b8","html_url":"https://github.com/gregory-ledenev/EasyRoutingClusterSample","commit_stats":null,"previous_names":["gregory-ledenev/easyroutingclustersample"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/gregory-ledenev/EasyRoutingClusterSample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-ledenev%2FEasyRoutingClusterSample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-ledenev%2FEasyRoutingClusterSample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-ledenev%2FEasyRoutingClusterSample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-ledenev%2FEasyRoutingClusterSample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregory-ledenev","download_url":"https://codeload.github.com/gregory-ledenev/EasyRoutingClusterSample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-ledenev%2FEasyRoutingClusterSample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273072734,"owners_count":25040582,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cluster","java","microservices","sample","tutorial","vertx"],"created_at":"2025-09-01T04:01:02.452Z","updated_at":"2025-09-01T04:02:04.867Z","avatar_url":"https://github.com/gregory-ledenev.png","language":"Java","readme":"# Sample Clustered/Microservices Application Using EasyRouting for Vert.x\n\nBuilding clustered applications and microservices can seem daunting. Typically, it requires deep knowledge, heavy\nconfiguration, and quite a bit of boilerplate code. However, with [EasyRouting](https://github.com/gregory-ledenev/vert.x-easyrouting) for Vert.x, you can get started with minimal setup and a very short learning curve.\n\nIn this tutorial, we’ll walk step-by-step through creating a simple clustered application using EasyRouting.\n\n***\n\n## Step 1: A Simple Hello World Application\n\nWe’ll begin by creating a basic EasyRouting app that responds to HTTP `GET` requests with “Hello World!”.\n\nFirst, set up a Maven project and add the EasyRouting dependency:\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.gregory-ledenev\u003c/groupId\u003e\n    \u003cartifactId\u003evert.x-easyrouting\u003c/artifactId\u003e\n    \u003cversion\u003e0.9.13\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nHere’s our minimal application:\n\n```java\npublic class ClusteredApplication extends Application {\n    @GET(\"/*\")\n    public String helloWorld() {\n        return \"Hello World!\";\n    }\n\n    public static void main(String[] args) {\n        new ClusteredApplication().start();\n    }\n}\n```\n\nRun this application and open a browser at [http://localhost:8080]() to see it in action.\n\n***\n\n## Step 2: Enabling Clustering\n\nTurning this into a clustered app is surprisingly easy - add the `clustered(\"main\")` initializer:\n\n```java\npublic class ClusteredApplication extends Application {\n    @GET(\"/*\")\n    public String helloWorld() {\n        return \"Hello World!\";\n    }\n\n    public static void main(String[] args) {\n        new ClusteredApplication()\n                .clustered(\"main\")\n                .start();\n    }\n}\n```\n\nOnce you run the app, you’ll see that it is now running in clustered mode and is part of a cluster — even if it’s\ncurrently the only member:\n\n```\nMembers {size:1, ver:1} [\n    Member [192.168.1.207]:5701 - 78278fe3-fdc3-4926-ac10-e870554b5659 this\n]\n```\nEasyRouting hides the complexity of forming a cluster, registering/unregistering nodes with it, etc. \n\n***\n\n## Step 3: Running Multiple Nodes\n\nLet’s extend this further and allow the app to run with multiple nodes. By passing in a port and a node name, we can\nallow starting  several instances of the same application on the same host.\n\n- If no arguments are given → node defaults to `\"main\"`, running on port `8080`.\n- Otherwise → node name = `\"node\u003cport\u003e\"` and it runs on the provided port.\n\n```java\npublic static void main(String[] args) {\n    int port = args.length \u003e 0 ? Integer.parseInt(args[0]) : 8080;\n    String nodeName = args.length \u003e 0 ? args[1] : \"node\" + port;\n\n    new ClusteredApplication()\n            .clustered(nodeName)\n            .start(port);\n}\n```\n\nYou can now launch multiple instances (e.g., \"main\" on `8080`, \"node1\" on \"`8081`, \"node2\" on \"`8082`), and they will automatically form a cluster:\n\n```\nMembers {size:3, ver:3} [\n    Member [192.168.1.207]:5701 - 78278fe3-fdc3-4926-ac10-e870554b5659\n    Member [192.168.1.207]:5702 - 6ccc86fb-9fd6-4489-a9e3-a95f9fd22d8c\n    Member [192.168.1.207]:5703 - 32fb07aa-edd0-4441-9d43-5f86f54bf0bb this\n]\n```\n\n***\n\n## Step 4: Inter-Node Communication\n\nNow that we have multiple nodes running, let’s make them talk to each other.\n\nImagine this setup:\n\n- **main node** → aggregates greetings.\n- **node1** and **node2** → provide their own greetings.\n\nThe question is: *How can the main node discover and talk to the microservice nodes?*\n\nThis is where EasyRouting helps us. It allows you to declare URIs for cluster members simply by using annotations with particular node names:\n\n```java\n\n@GET(\"/*\")\npublic String helloWorld(@ClusterNodeURI(\"node1\") URI node1,\n                         @ClusterNodeURI(\"node2\") URI node2) {\n    // add your code here\n}\n```\n\nEasyRouting automatically discovers and injects the addresses of running nodes with the given names — no manual discovery or\nconfiguration required.\n\n***\n\n## Step 5: Collecting Greetings from Nodes\n\nLet’s finish the `helloWorld` method by fetching greetings from the other nodes and aggregating them:\n\n```java\n\n@GET(\"/*\")\npublic String helloWorld(@ClusterNodeURI(\"node1\") URI node1,\n                         @ClusterNodeURI(\"node2\") URI node2) {\n    HttpClient client = HttpClient.newHttpClient();\n    List\u003cString\u003e result = new ArrayList\u003c\u003e();\n\n    result.add(\"Hello World!\");\n    getHelloFromNode(client, node1, result);\n    getHelloFromNode(client, node2, result);\n\n    return String.join(\", \", result);\n}\n```\nNote: this code uses `getHelloFromNode()` method that fetches greetings and the  `helloFromNode()` handler that provide actual greeting - check the project to get them.\n\nRun the main node and start up `node1` and `node2`. Now, when you open [http://localhost:8080](), the main node will return a **collective greeting**:\n\n```\nHello World!, Hello from 'node1', Hello from 'node2'\n```\n\n***\n\n## Conclusion\n\nIn just a handful of lines, we’ve gone from a simple standalone “Hello World” app to a minimal **clustered microservices setup** with internode communication — powered by Vert.x and EasyRouting.\n\nWith:\n\n- a couple of annotations,\n- minimal configuration, and\n- a clean programming model,\n\nyou’re ready to scale your Vert.x applications into clustered environments.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregory-ledenev%2Feasyroutingclustersample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregory-ledenev%2Feasyroutingclustersample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregory-ledenev%2Feasyroutingclustersample/lists"}