{"id":25720065,"url":"https://github.com/gregwhitaker/nats-requestreply-example","last_synced_at":"2026-06-12T04:31:04.854Z","repository":{"id":82732571,"uuid":"119005291","full_name":"gregwhitaker/nats-requestreply-example","owner":"gregwhitaker","description":"An example of using NATS for request-reply messaging","archived":false,"fork":false,"pushed_at":"2018-01-26T20:32:14.000Z","size":80,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T17:41:31.150Z","etag":null,"topics":["messaging","nats","nats-messaging","natsio","request-reply"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregwhitaker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-01-26T04:23:31.000Z","updated_at":"2022-03-15T11:39:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"e57d5304-39b4-4d4b-85c7-886c82ab47a0","html_url":"https://github.com/gregwhitaker/nats-requestreply-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gregwhitaker/nats-requestreply-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fnats-requestreply-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fnats-requestreply-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fnats-requestreply-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fnats-requestreply-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregwhitaker","download_url":"https://codeload.github.com/gregwhitaker/nats-requestreply-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregwhitaker%2Fnats-requestreply-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34229624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"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":["messaging","nats","nats-messaging","natsio","request-reply"],"created_at":"2025-02-25T17:36:28.960Z","updated_at":"2026-06-12T04:31:04.849Z","avatar_url":"https://github.com/gregwhitaker.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nats-requestreply-example\n[![Build Status](https://travis-ci.org/gregwhitaker/nats-requestreply-example.svg?branch=master)](https://travis-ci.org/gregwhitaker/nats-requestreply-example)\n\nAn example of using [NATS](https://nats.io) for request-reply messaging.\n\nThis example starts a service that responds with `World! from {server id}` when it receives a request with the message `hello`. If you are running multiple service\ninstances, requests will be automatically load-balanced between them.\n\n## Background\nNATS supports two flavors of request reply messaging: point-to-point or one-to-many. Point-to-point involves the fastest or first to respond. In a one-to-many exchange, you set a limit on the number of responses the requestor may receive.\n\nIn a request-response exchange, publish request operation publishes a message with a reply subject expecting a response on that reply subject. You can request to automatically wait for a response inline.\n\nThe request creates an inbox and performs a request call with the inbox reply and returns the first reply received. This is optimized in the case of multiple responses.\n\nMore information can be found in the [NATS Documentation](https://nats.io/documentation/concepts/nats-req-rep/).\n\n## Prerequisites\nThe examples require a local NATS server to be running. To start a NATS server as a Docker container run the following commands:\n\n    $ docker pull nats\n    $ docker run -p 4222:4222 -p 6222:6222 -p 8222:8222 -d --name nats-main nats\n\n## Running the Example\n### Start the Request-Reply Client\nYou can start the [Request-Reply Client](requestreply-client/README.md) using the following command:\n\n    $ ./gradlew :requestreply-client:run\n    \nOnce the client and service is running you will see messages similar to the following in the terminal:\n\n    [main] INFO nats.example.requestreply.client.Main - Starting NATS Example Request-Reply Client\n    [main] INFO nats.example.requestreply.client.Main - SENT: Hello\n    [main] INFO nats.example.requestreply.client.Main - RECEIVED: World! from 494ad392-e136-4c40-9d1f-69a2d75a5ce6\n\n### Start the Request-Reply Service\nYou can start the [Request-Reply Service](requestreply-service/README.md) using the following command:\n\n    $ ./gradlew :requestreply-service:run\n\nOnce the client and service is running you will see messages similar to the following in the terminal:\n\n    [main] INFO nats.example.requestreply.service.Main - Starting NATS Example Request-Reply Service 2c84095d-6a17-4db1-86c3-6d41eb247d9e\n    [jnats-subscriptions] INFO nats.example.requestreply.service.Main - Received Message From _INBOX.9VgixJvxwVp7Ehi8gej7GJ: Hello\n    [jnats-subscriptions] INFO nats.example.requestreply.service.Main - Received Message From _INBOX.9VgixJvxwVp7Ehi8gej7IK: Hello\n    [jnats-subscriptions] INFO nats.example.requestreply.service.Main - Received Message From _INBOX.9VgixJvxwVp7Ehi8gej7KL: Hello\n\nYou can start multiple services and see that requests are automatically load-balanced between the instances.\n\n## Bugs and Feedback\nFor bugs, questions and discussions please use the [Github Issues](https://github.com/gregwhitaker/nats-requestreply-example/issues).\n\n## License\nMIT License\n\nCopyright (c) 2018 Greg Whitaker\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwhitaker%2Fnats-requestreply-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregwhitaker%2Fnats-requestreply-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregwhitaker%2Fnats-requestreply-example/lists"}