{"id":23483875,"url":"https://github.com/codesmell/asynchrest","last_synced_at":"2025-08-18T17:13:38.810Z","repository":{"id":108722436,"uuid":"73194970","full_name":"CodeSmell/AsynchRest","owner":"CodeSmell","description":"Playing with Spring Boot and asynch REST","archived":false,"fork":false,"pushed_at":"2018-02-28T23:27:14.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T02:35:06.378Z","etag":null,"topics":["asynch-rest","completablefuture","jersey","spring-boot"],"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/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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-08T14:41:27.000Z","updated_at":"2017-08-04T02:13:26.000Z","dependencies_parsed_at":"2023-03-12T09:30:50.857Z","dependency_job_id":null,"html_url":"https://github.com/CodeSmell/AsynchRest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CodeSmell/AsynchRest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FAsynchRest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FAsynchRest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FAsynchRest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FAsynchRest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeSmell","download_url":"https://codeload.github.com/CodeSmell/AsynchRest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeSmell%2FAsynchRest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271027687,"owners_count":24687082,"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-08-18T02:00:08.743Z","response_time":89,"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":["asynch-rest","completablefuture","jersey","spring-boot"],"created_at":"2024-12-24T21:16:25.075Z","updated_at":"2025-08-18T17:13:38.782Z","avatar_url":"https://github.com/CodeSmell.png","language":"Java","readme":"# Asynch REST\nExamine Spring MVC \u0026 Jersey as REST API framework within Spring Boot\n\nPlaying with various asynchronous \u0026 parallel processing options\n\n## Running the examples\nSpring MVC will run using the following URL path\n\t\n\tlocalhost:8888/springmvc/hello\n\t\n\tlocalhost:8888/springmvc/invoice/find/?storeNumber=100\u0026trailerNumber=1\n\nJersey/JAX-RS will run using the following URL path\n\t\n\tlocalhost:8888/jaxrs/hello\n\t\n\tlocalhost:8888/jaxrs/invoice/find/?storeNumber=100\u0026trailerNumber=1\n\n### Testing stream\nIn order to see the stream in action, update the `SlowInvoiceDao` so that it returns 5000 invoices. Also update the `Thread.sleep` to 100 ms.\n\n\tcurl localhost:8888/jaxrs/invoice/find/stream?storeNumber=100\n\nThe resulting array of JSON objects will start to be returned before the method has completed.\n\t\n## Using Jersey as JAX-RS provider instead of Spring MVC\nTypically a Spring Boot application will use the web starter, which sets up the container for Spring MVC REST development.\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n      \u003cartifactId\u003espring-boot-starter-web\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n\n\nSwitch that starter out for the following Jersey one (or in our case leave them both in, since we are comparing them)\n\n    \u003cdependency\u003e\n      \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n      \u003cartifactId\u003espring-boot-starter-jersey\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n    \n### Issue w/ Jersey and Spring Boot\n[Jersey doesn't always work with Spring Boot fat jars (1468)](https://github.com/spring-projects/spring-boot/issues/1468)   \n\nThis issue presented when adding the `packages()` to `JerseyConfig`  \n\n\t@Configuration\n\t@ApplicationPath(\"/jaxrs\")\n\tpublic class JerseyConfig extends ResourceConfig {\n\t\n\t    public JerseyConfig() {\n\t        register(HelloJerseyController.class);\n\t        register(JaxRsInvoiceController.class);\n\t        register(JaxRsAsynchInvoiceController.class);\n\t        //packages(\"codesmell.invoice.rest.jaxrs.mappers\");\n\t    }\n\t}\n\t\nTo get around it the `ExceptionMapper` classes were registered directly.\t\n\n## building and running the application\n\nThe simulator can be run from Maven command line:\n\n    mvn spring-boot:run\n    \nIt can also be built and run as a \"fat jar\"\n\n    mvn package spring-boot:repackage\n    \nThis builds the JAR file that contains all of the dependencies, including the container.\n    \n    java -jar target/rx-invoice-[version].jar\n\n## The scenario being solved \nImagine that we are storing invoices in an Apache Cassandra database.\n\nAssume a keyspace that has two tables. \nOne allows queries to retrieve all of the invoices going to the same place and on the same trailer.\n\n\tCREATE TABLE IF NOT EXISTS \"invoices_by_destination\" (\n\t\tinvoice_id TEXT,\n\t\tdestination_name TEXT,\n\t\tdestination_type TEXT,\n\t\ttrailer TEXT,\n\t\tPRIMARY KEY ((destination_name, destination_type), trailer, invoice_id));\n\nAnother stores the JSON document with all of the details for a single invoice.\n\t\n\tCREATE TABLE IF NOT EXISTS \"invoice_detail\" (\n\t\tinvoice_id TEXT,\n\t\tjson_doc TEXT,\n\t\tPRIMARY KEY ((invoice_id)));\t\n\n\nNow we have a scenario where we are searching for a list of invoices and then want to return JSON that contains an array of invoice documents. Note: the sample code uses a small JSON representation of an invoice.\n\n\t[\n\t\t{\"invoice\": {\n\t\t\t\"id\": \"1\",\n\t\t\t\"foo\": \"bar\"}\n\t\t},\n\t\t{\"invoice\": {\n\t\t\t\"id\": \"2\",\n\t\t\t\"foo\": \"fighters\"}\n\t\t}\n\t]\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesmell%2Fasynchrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodesmell%2Fasynchrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesmell%2Fasynchrest/lists"}