ibm-messaging / mq-asyncapi-java-template

This repository is no longer used and the project is now hosted within the ASyncAPI organisation.
https://github.com/asyncapi/java-template
Apache License 2.0
4 stars 1 forks source link
asyncapi generator hacktoberfest java template

AsyncAPI logo
AsyncAPI Java Generator

Overview

This template generates Java application code based from an AsyncAPI document.

Implementations are provided for the following protocols:

Technical requirements

Supported protocols

How to use the template

This template must be used with the AsyncAPI Generator. You can find all available options here.

CLI

# Install the AsyncAPI Generator
npm install -g @asyncapi/generator

# Run generation
ag https://ibm.biz/mq-asyncapi-yml-sample https://ibm.biz/asyncapi-java-template -o output -p server=production

Template Tutorial

For complete instructions on generating the Java and subsequently using it to send messages, please see the relevant tutorial:

Template configuration

You can configure this template by passing different parameters in the Generator CLI: -p PARAM1_NAME=PARAM1_VALUE -p PARAM2_NAME=PARAM2_VALUE

Name Description Required Default
server Server must be defined in yaml and selected when using the generator Yes -
user User for the server to generate code for. This can also be provided as an environment variable (see below) No app
password Password for the server to generate code for. This can also be provided as an environment variable (see below) No passw0rd
package Java package name for generated code No com.ibm.mq.samples.jms
mqTopicPrefix MQ topic prefix. Used for ibmmq protocols. Default will work with dev MQ instance No dev//

Environment variables

Credentials can be provided as environment variables if preferred. If set, these credentials will override those set with the template parameters.

Name Description
APP_USER Overrides user template parameter
APP_PASSWORD Overrides password template parameter

All 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.

Development

The most straightforward command to use this template is:

ag https://ibm.biz/mq-asyncapi-yml-sample https://ibm.biz/asyncapi-java-template -o output -p server=production

For local development, you need different variations of this command. First of all, you need to know about three important CLI flags:

There are two ways you can work on template development:

Key Files

As 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.

Generator Code

Path Description
template/index.js Entry point for the application
components/Common.js Common/helper functions used across the generator
utils/* Contains all filters
components/* Contains reusable components

Generated Code

Note: Files in the output directory are generated using the ag command, detailed in the above section.

Path Description
output/env.json Used for setting environmental variables such as username and password
output/com/ibm/mq/samples/jms/PubSubBase.java The base used for generated publishers and subscribers

Container Information

To run the generated Java project in a Docker container, use the commands as below:

  1. Build the image

    docker build -t [PACKAGE_NAME]:[VERSION] .
  2. Run the image in detached mode

    docker run -d [PACKAGE_NAME]:[VERSION]

For further information including network setup, please see the tutorial.

Future Enhancements

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Dan Raper

πŸ’» πŸ“–

Tom Jefferson

πŸ’» βœ… πŸ“–

Lewis Relph

πŸ’» πŸ“– ⚠️

Kieran Murphy

πŸ’» πŸ“– ⚠️

Akshaya Gurlhosur

πŸ“– ⚠️

Dale Lane

πŸ’» πŸ“–

This project follows the all-contributors specification. Contributions of any kind welcome!