{"id":19076388,"url":"https://github.com/axway-streams/axway-amplify-streams-java-sdk","last_synced_at":"2025-02-22T05:19:17.640Z","repository":{"id":45535951,"uuid":"113554542","full_name":"axway-streams/axway-amplify-streams-java-sdk","owner":"axway-streams","description":"A java SDK to allow users to get the best of streamdata.io in a few lines of code.","archived":false,"fork":false,"pushed_at":"2022-11-16T12:22:06.000Z","size":45,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-02T18:24:50.614Z","etag":null,"topics":["java","server-sent-events","sse","streamdataio","streaming-data"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axway-streams.png","metadata":{"files":{"readme":"README.adoc","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}},"created_at":"2017-12-08T09:05:48.000Z","updated_at":"2019-07-16T20:21:45.000Z","dependencies_parsed_at":"2023-01-21T19:22:25.039Z","dependency_job_id":null,"html_url":"https://github.com/axway-streams/axway-amplify-streams-java-sdk","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axway-streams%2Faxway-amplify-streams-java-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axway-streams%2Faxway-amplify-streams-java-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axway-streams%2Faxway-amplify-streams-java-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axway-streams%2Faxway-amplify-streams-java-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axway-streams","download_url":"https://codeload.github.com/axway-streams/axway-amplify-streams-java-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240128146,"owners_count":19752124,"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":["java","server-sent-events","sse","streamdataio","streaming-data"],"created_at":"2024-11-09T01:59:12.487Z","updated_at":"2025-02-22T05:19:17.582Z","avatar_url":"https://github.com/axway-streams.png","language":"Java","readme":"\n== Axway AMPLIFY Streams Java SDK\n\n\n=== What does the API do?\n\nIt connects to the server with some your API URL and your credentials (API key) and you get notified using either\n\n* Some callback you provide\n* Through an RxJava2 `Flowable`\n\nYou can choose to receive snapshots only or one snapshot and then patches you don't even know SSE is used, you just use your data.\n\n=== Step by step setup to run demo\n\n* Create an free account on Axway AMPLIFY Streams https://portal.streamdata.io/#/register to get an App token.\n* Clone project, edit Main.java and replace [YOUR TOKEN HERE] with your App token.\n* Make sure you have Java 8+ installed\n* Make sure you have maven 3.0+ installed\n* Build project with maven:\n\n    `mvn clean install`\n\n* Run sample from a terminal:\n\n    `java -jar target/streamdataio-java-sdk-1.0.jar`\n\n* You should see data and patches pushed in your application and displayed on your terminal.\n* You can build the jar on your own and use provided classes to use this API.\nYou can use the provided demo which stream an API of factice financial market: 'http://stockmarket.streamdata.io/v2/prices'\n\nFeel free to test it with any REST/Json API of your choice. You can add authorization headers and query params.\n\n\n=== How to integrate the API into your project\n\n*Maven*\n\n_after building this project_\n\n[xml]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.streamdata\u003c/groupId\u003e\n    \u003cartifactId\u003ejava-sdk\u003c/artifactId\u003e\n    \u003cversion\u003e1.0\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\n*Gradle*\n\n----\ndependencies {\n    compile(\"io.streamdata:java-sdk:1.0\")\n}\n----\n\nNotable transitive dependencies :\n\n* Glassfish Jersey as EventSource client (https://jersey.java.net/documentation/latest/sse.html)\n* RxJava 2 (https://github.com/ReactiveX/RxJava)\n* Jackson for Json processing  (http://wiki.fasterxml.com/JacksonHome).\n* zjsonpatch (https://github.com/flipkart-incubator/zjsonpatch) as a Java Json-Patch implementation\n* Slf4j with a default configuration\n\n=== Callback based API\n\nThis API is based on callbacks and is very similar to our Node.js API.\n\n[java]\n----\n\nString apiURL = \"http://api.mycompany.com/prices\";\nString appKey = \"YOUR OWN APP KEY\";                                             # \u003c1\u003e\n\nEventSourceClient client = StreamdataClient.createClient(apiURL, appKey);\nclient.addHeader(\"X-MYAPI-POLLER\", \"Polled By SD.io\")                           # \u003c2\u003e\n        .useJsonPatch(true)                                                     # \u003c3\u003e\n        .onSnapshot(this::processData)                                          # \u003c4\u003e\n        .onPatch(patch -\u003e this.processPatch(patch, client.getCurrentSnaphot())) # \u003c5\u003e\n        .onOpen(() -\u003e logger.info(\"And we are... live!\"))                       # \u003c6\u003e\n        .onClose(() -\u003e logger.info(\"And we are... dead!\"))                      # \u003c7\u003e\n        .onError(err -\u003e logger.error(\"An error occured {}\", err))               # \u003c8\u003e\n        .onException(ex -\u003e logger.error(\"Unexpected error\", ex))                # \u003c9\u003e\n        .open();                                                                # \u003c10\u003e\n----\n\n\u003c1\u003e This the key you when you created your app in the web portal.\n\u003c2\u003e Headers to be added when polling your API (Typically some auth header) [_Optional_ ]\n\u003c3\u003e This allows you let streamdata send snapshots only (set `false` to do so) or snapshot then patch (default behaviour if you don't call this method) [_Optional_ ]\n\u003c4\u003e A callback that will consume the snapshot\n\u003c5\u003e A callback that will consume the patch (you can access the snaphost anyways) [_Optional_ ]\n\u003c6\u003e Called when successfully open the connection [_Optional_ ]\n\u003c7\u003e Called the connection is actually closed [_Optional_ ]\n\u003c6\u003e Called when the stream return an error, by default the error is logged. Usually it is recommended to close the connection: ```client.close()``` [_Optional_ ]\n\u003c7\u003e Call when an error occurs, mainly when opening the event source, by default the error is logged but it is recommended to close the connection: ```client.close()``` [_Optional_ ]\n\u003c10\u003e Open the connection with the server and start streamdata.\n\n\n=== RxJava based API\n\nThis API relies on the previous one but expose a rx's Flowable interface to handle data coming from the server.\nData is wrapped in a simple Event class allowing you to know is the data is an error a patch or a snapshot.\n\n\n[java]\n----\n\nString apiURL = \"http://api.mycompany.com/prices\";\nString appKey = \"YOUR OWN APP KEY\";                                             # \u003c1\u003e\n\n\nStreamdataClient.createRxJavaClient(apiURL, appKey)\n            .addHeader(\"X-MYAPI-POLLER\", \"Polled By SD.io\")                     # \u003c2\u003e\n            .useJsonPatch(true)                                                 # \u003c3\u003e\n            .toFlowable()                                                       # \u003c4\u003e\n            // here you can add operator to manipulate the flow\n            .subscribe(event -\u003e {                                               # \u003c5\u003e\n                if (event.isSnapshot()) {\n                    this.processData(event.getSnapshot())\n                } else if (event.isPatch()) {\n                    this.processData(event.getPatch(), event.getSnapshot())\n                } else if (event.isError()) {\n                    throw new RuntimeException(event.getError().toString());    # \u003c6\u003e\n                }\n            }, err -\u003e logger.error(err.getMessage(), err));\n\n----\n\u003c1\u003e Same as above\n\u003c2\u003e Same as above\n\u003c3\u003e Same as above\n\u003c4\u003e Once configured you can start manipulating you data or use specific schedulers \n\u003c5\u003e An example without using any rx operators before show you available methods on event\n\u003c6\u003e Shis will stop the flowable and disconnect the event source\n\n== Errors\n\nErrors not a simple string. It is JSON!\n\nAbove, an example of an error so you can get more detailed informations.\n\n[JSON]\n```\n{\n    \"status\":2005,\n    \"cause\":\"An error occurred while streaming http://stockmarket.streamdata.io/priceshttp://stockmarket.streamdata.io/prices. : HTTP/1.1 404 \",\n    \"message\":\"HTTP error. The Http response cannot be processed.\",\n    \"timestamp\":1512566770744,\n    \"sessionId\":\"62fd67bc-d090-4333-a783-d94b366f55f4\"\n}\n```\n\n== Contributing\n\nPlease read\nhttps://github.com/axway-amplify-streams/Common/blob/master/Contributing.md[Contributing.md]\nfor details on our code of conduct, and the process for submitting pull\nrequests to us.\n\n== Team\n\nimage:https://github.com/axway-amplify-streams/Common/blob/master/img/AxwayLogoSmall.png[alt\ntext,title=\"Axway logo\"] Axway Team\n\n== License\n\nhttps://github.com/axway-amplify-streams/Common/blob/master/LICENSE[Apache\nLicense 2.0]\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxway-streams%2Faxway-amplify-streams-java-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxway-streams%2Faxway-amplify-streams-java-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxway-streams%2Faxway-amplify-streams-java-sdk/lists"}