{"id":16809507,"url":"https://github.com/asyncapi/java-template","last_synced_at":"2025-05-12T03:31:45.173Z","repository":{"id":39608788,"uuid":"442422660","full_name":"asyncapi/java-template","owner":"asyncapi","description":"Java template for the AsyncAPI Generator","archived":false,"fork":false,"pushed_at":"2025-03-28T16:11:58.000Z","size":11022,"stargazers_count":15,"open_issues_count":6,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T10:29:40.023Z","etag":null,"topics":["asyncapi","generator","nodejs","template"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/asyncapi.png","metadata":{"funding":{"github":"asyncapi","patreon":null,"open_collective":"asyncapi","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null},"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-28T10:05:28.000Z","updated_at":"2025-04-15T01:15:31.000Z","dependencies_parsed_at":"2024-02-19T13:06:05.116Z","dependency_job_id":"0be6f72b-c20b-4b37-a62d-a388bbf7c116","html_url":"https://github.com/asyncapi/java-template","commit_stats":{"total_commits":288,"total_committers":19,"mean_commits":"15.157894736842104","dds":0.5208333333333333,"last_synced_commit":"cfc38ad958a0d31a4b8b1ab5785811f3acb304ea"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fjava-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fjava-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fjava-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fjava-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asyncapi","download_url":"https://codeload.github.com/asyncapi/java-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252100767,"owners_count":21694743,"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":["asyncapi","generator","nodejs","template"],"created_at":"2024-10-13T10:13:03.318Z","updated_at":"2025-05-12T03:31:45.133Z","avatar_url":"https://github.com/asyncapi.png","language":"JavaScript","readme":"[![AsyncAPI Java Generator](./assets/logo.png)](https://www.asyncapi.com)\n\n\n\u003c!-- toc --\u003e\n\n- [Overview](#overview)\n- [Technical requirements](#technical-requirements)\n- [Supported protocols](#supported-protocols)\n- [How to use the template](#how-to-use-the-template)\n  - [CLI](#cli)\n  - [Template Tutorial](#template-tutorial)\n- [Template configuration](#template-configuration)\n- [Environment variables](#environment-variables)\n- [Development](#development)\n- [Key Files](#key-files)\n  - [Generator Code](#generator-code)\n  - [Generated Code](#generated-code)\n- [Container Information](#container-information)\n- [Future Enhancements](#future-enhancements)\n- [Contributors ✨](#contributors-)\n\n\u003c!-- tocstop --\u003e\n\n## Overview\n\nThis template generates Java application code based from an AsyncAPI document.\n\nImplementations are provided for the following protocols:\n* `ibmmq` - generating Java JMS code (utilising features from the [IBM MQ AsyncAPI bindings](https://github.com/asyncapi/bindings/tree/master/ibmmq))\n* `kafka` - generating Java code  (utilising features from the [Apache Kafka AsyncAPI bindings](https://github.com/asyncapi/bindings/tree/master/kafka))\n\n## Technical requirements\n\n- 0.50.0 =\u003c [Generator](https://github.com/asyncapi/generator/) \u003c 2.0.0,\n- Generator specific [requirements](https://github.com/asyncapi/generator/#requirements)\n\n\n## Supported protocols\n\n* ibmmq\n    * This is implemented using the JMS API with the correct jars, in this case ibmmq was chosen. The use of JMS allows allows the template to be extensible to other providers by providing the correct jars at the Maven stage.\n* kafka\n    * This is implemented using the official client library from the Apache Kafka project.\n\n## How to use the template\n\nThis template must be used with the AsyncAPI Generator. You can find all available options [here](https://github.com/asyncapi/generator/).\n\n### CLI\n\n```sh\n# Install the AsyncAPI Generator\nnpm install -g @asyncapi/generator\n\n# Run generation\nag https://ibm.biz/mq-asyncapi-yml-sample @asyncapi/java-template -o output -p server=production\n\n```\n### Template Tutorial\nFor complete instructions on generating the Java and subsequently using it to send messages, please see the relevant tutorial:\n- [ibmmq tutorial](./tutorials/IBMMQ.md)\n- [kafka tutorial](./tutorials/KAFKA.md)\n\n\n## Template configuration\n\nYou can configure this template by passing different parameters in the Generator CLI: `-p PARAM1_NAME=PARAM1_VALUE -p PARAM2_NAME=PARAM2_VALUE`\n\nName | Description | Required | Default\n---|---|---|---\n`server` | Server must be defined in yaml and selected when using the generator | Yes | -\n`user` | User for the server to generate code for. This can also be provided as an environment variable (see below) | No | app\n`password` | Password for the server to generate code for. This can also be provided as an environment variable (see below) | No | passw0rd\n`package` | Java package name for generated code | No | com.asyncapi\n`mqTopicPrefix` | MQ topic prefix. Used for ibmmq protocols. Default will work with dev MQ instance | No | dev//\n`asyncapiFileDir` | Custom output location of the AsyncAPI file that you provided as an input | No | The root of the output directory\n\n\n## Environment variables\n\nCredentials can be provided as environment variables if preferred. If set, these credentials will override those set with the template parameters.\n\nName | Description\n---|---\n`APP_USER` | Overrides `user` template parameter\n`APP_PASSWORD` | Overrides `password` template parameter\n\nAll credentials are stored in `env.json` in the output directory, so they can be updated at any time without needing to run the generator or recompile the Java.\n\n## Development\n\nThe most straightforward command to use this template is:\n```sh\nag https://ibm.biz/mq-asyncapi-yml-sample @asyncapi/java-template -o output -p server=production\n```\n\nFor local development, you need different variations of this command. First of all, you need to know about three important CLI flags:\n- `--debug` enables the debug mode in Nunjucks engine what makes filters debugging simpler.\n- `--watch-template` enables a watcher of changes that you make in the template. It regenerates your template whenever it detects a change.\n- `--install` enforces reinstallation of the template.\n\n\nThere are two ways you can work on template development:\n- Use global Generator and template from your local sources:\n  ```sh\n  # assumption is that you run this command from the root of your template\n  ag https://ibm.biz/mq-asyncapi-yml-sample @asyncapi/java-template -o output -p server=production\n  ```\n- Use Generator from sources and template also from local sources. This approach enables more debugging options with awesome `console.log` in the Generator sources or even the Parser located in `node_modules` of the Generator:\n  ```sh\n  # assumption is that you run this command from the root of your template\n  # assumption is that generator sources are cloned on the same level as the template\n  ../generator/cli.js https://ibm.biz/mq-asyncapi-yml-sample @asyncapi/java-template -o output -p server=production\n  ```\n\n## Key Files\nAs a developer, you may want to make changes to how the generator operates. This non-exhaustive list aims to show the files you will likely need to change most.\n\n\n### Generator Code\n\nPath | Description\n---|---\ntemplate/index.js | Entry point for the application\ncomponents/Common.js | Common/helper functions used across the generator\nutils/* | Contains all filters\ncomponents/* | Contains reusable components\n\n### Generated Code\n***Note:***  Files in the output directory are generated using the ag command, detailed in the above section.\n\nPath | Description\n---|---\noutput/env.json | Used for setting environmental variables such as username and password\noutput/com/asyncapi/PubSubBase.java | The base used for generated publishers and subscribers\n\n\n## Container Information\nTo run the generated Java project in a Docker container, use the commands as below:\n\n1. Build the image\n   ```\n    docker build -t [PACKAGE_NAME]:[VERSION] .\n   ```\n\n2. Run the image in detached mode\n   ```\n    docker run -d [PACKAGE_NAME]:[VERSION]\n   ```\n\nFor further information including network setup, please see the [tutorial](./tutorials).\n\n## Future Enhancements\n* General enhancements\n    * Add support for multiple messages per channel (ofMany)\n    * Support for MQTT\n    * Support for other protocols\n* `ibmmq` protocol enhancements\n    * Add support for TLS connections\n    * Add support for more JMS Types alongside JMS Text\n    * Offer Java event listener support for consumers\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/dan-r\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1384852?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDan Raper\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/java-template/commits?author=dan-r\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=dan-r\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/JEFFLUFC\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/54025356?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTom Jefferson\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/java-template/commits?author=JEFFLUFC\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#tutorial-JEFFLUFC\" title=\"Tutorials\"\u003e✅\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=JEFFLUFC\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/lewis-relph\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/91530893?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eLewis Relph\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/java-template/commits?author=lewis-relph\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=lewis-relph\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=lewis-relph\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/KieranM1999\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/45017928?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKieran Murphy\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/java-template/commits?author=KieranM1999\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=KieranM1999\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=KieranM1999\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/AGurlhosur\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/91530186?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAkshaya Gurlhosur\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/java-template/commits?author=AGurlhosur\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=AGurlhosur\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/dalelane\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1444788?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDale Lane\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/java-template/commits?author=dalelane\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/java-template/commits?author=dalelane\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","funding_links":["https://github.com/sponsors/asyncapi","https://opencollective.com/asyncapi"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncapi%2Fjava-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasyncapi%2Fjava-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncapi%2Fjava-template/lists"}