You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .tp-config.json
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,10 @@
48
48
"description": "The version of the solace-spring-cloud-bom dependency used when generating an application. Alternatively you can set the specification extension info.x-solace-spring-cloud-version.",
49
49
"required": false
50
50
},
51
+
"springBootVersion": {
52
+
"description": "The version of Spring Boot used when generating an application. Alternatively you can set the specification extension info.x-spring-booot-version. Example: 2.2.6.RELEASE.",
53
+
"required": false
54
+
},
51
55
"springCloudVersion": {
52
56
"description": "The version of the spring-cloud-dependencies BOM dependency used when generating an application. Alternatively you can set the specification extension info.x-spring-cloud-version. Example: Hoxton.RELEASE.",
Copy file name to clipboardExpand all lines: README.md
+49-31Lines changed: 49 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,11 @@
2
2
3
3
This template generates a Spring Cloud Stream (SCSt) microservice. It uses version 3 of SCSt which uses function names to configure the channels. See the [reference](https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.1.RELEASE/reference/html/spring-cloud-stream.html). The generated microservice is a Maven project so it can easily be imported into your IDE.
4
4
5
+
This template has been tested with Kafka, RabbitMQ and Solace.
6
+
5
7
The Spring Cloud Stream microservice generated using this template will be an _almost ready to run_ Spring Boot app. The microservice will contain a java class, by default _Application.java_, which includes methods which publish or subscribe events as defined in the AsyncAPI document. These generated methods include Supplier, Consumer and Function functional interfaces from the [java.util.function](https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html) package. These methods will already be pre-configured to publish to and consume from the channels as defined in the AsyncAPI. This configuration is located in the `spring.cloud.stream` section of the generated application.yml file.
6
8
9
+
Note that this template ignores the 'Servers' section of AsyncAPI documents. The main reason for this is because SCSt does not directly work with messaging protocols. Protocols are implementation details specific to binders, and SCSt applications need not know or care which protocol is being used.
7
10
8
11
## How it works
9
12
Note that this template interprets the AsyncAPI document from the perspective of an application, not an API. This means that when the template sees a subscribe operation, it generates code to subscribe to a topic, not publish to one.
@@ -20,16 +23,25 @@ The generated methods are named as follows:
20
23
* For each operation (i.e. _publish_ or _subscribe_ in each channel), the template looks for the specification extention ```x-scs-function-name```. If present, it uses that to name the function.
21
24
* If using the same ```x-scs-function-name``` on one _publish_ operation and one _subscribe_ operation to create a Function the name of the generated method will be the ```x-scs-function-name```
22
25
* If there is no ```x-scs-function-name``` attribute, the generator checks the operation's operationId value. If set, that is used as the function name.
23
-
* If there is no ```x-scs-function-name``` or operationId available, then a name will be generated by taking the channel name, removing non-alphabetic characters, converting to camel case, and appending 'Supplier' or 'Producer.' For example, if there is a channel called store/process with a publisher operation with a payload called Order, This method will get generated:
26
+
* If there is no ```x-scs-function-name``` or operationId available, then a name will be generated by taking the channel name, removing non-alphanumeric characters, converting to camel case, and appending 'Supplier' or 'Producer.' For example, if there is a channel called store/process with a publisher operation with a payload called Order, This method will get generated:
24
27
```
25
28
@Bean
26
29
public Supplier<Order> storeProcessSupplier () {
27
30
// Add business logic here.
28
31
return null;
29
32
}
30
33
```
34
+
### Property Naming
35
+
36
+
When converting from property names to Java field names, the property names are first converted to camelCase, removing non-alphanumeric characters in the process. If the resulting name ends up being a Java keyword, it is prepended with an underscore.
37
+
38
+
### Application vs Library
39
+
40
+
By default, this will generate a runnable Spring Boot application. If you set the ```artifactType``` parameter to ```library```, then it will generate a project without a main Application class and without the main Spring Boot dependencies. That will produce a library that can be imported into another application as a Maven artifact. It will contain the model classes and the Spring Cloud Stream configuration.
31
41
32
-
## How to Use
42
+
Doing that allows you to hava a clean separation between the generated code and your hand-written code, and ensures that regenerating the library will not overwrite your business logic.
43
+
44
+
## How to Use This Template
33
45
34
46
Install the AsyncAPI Generator
35
47
```
@@ -46,9 +58,12 @@ Run the Generator using the Java Spring Cloud Stream Template with Parameters
Please note that none of the parameters or specification extensions is required. All have defaults as documented below.
64
+
65
+
Any parameters or specification extensions that include the name 'Solace' only have an effect when the Solace binder is specified. If and when other binder-specific parameters are added to this template, they will follow a similar naming pattern.
66
+
52
67
### Destination Overrides
53
68
54
69
There are two specification extentions you can use to shape how the bindings are configured. You can add the following to a _subscribe_ operation:
@@ -61,39 +76,42 @@ There are two specification extentions you can use to shape how the bindings are
61
76
62
77
Parameters can be passed to the generator using command line arguments in the form ```-p param=value -p param2=value2```. Here is a list of the parameters that can be used with this template. In some cases these can be put into the AsyncAPI documents using the specification extensions feature. In those cases, the 'info' prefix means that it belongs in the info section of the document.
63
78
64
-
Parameter | Extension | Description
65
-
------------|--------------|------------------
66
-
actuator | | If present, it adds the dependencies for spring-boot-starter-web, spring-boot-starter-actuator and micrometer-registry-prometheus.
67
-
artifactId | info.x-artifact-id | The Maven artifact id.
68
-
artifactType | | The type of project to generate, application or library. The default is library. When generating an application, the pom.xml file will contain the complete set of dependencies required to run an app, and it will contain an Application class with a main function. Otherwise the pom file will include only the dependencies required to compile a library.
69
-
binder | | The name of the binder implementation, one of kafka, rabbit or solace. Default: kafka. If you need other binders to be supported, please let us know!
70
-
groupId | info.x-group-id | The Maven group id.
71
-
host | | The host connection property. Currently this only works with the Solace binder. Example: tcp://myhost.com:55555
72
-
javaPackage | info.x-java-package | The Java package of the generated classes.
73
-
msgVpn | | The message vpn connection property. Currently this only works with the Solace binder.
74
-
password | | The client password connection property. Currently this only works with the Solace binder.
75
-
reactive | | If true, the generated functions will use the Reactive style and use the Flux class.
76
-
solaceSpringCloudVersion | info.x-solace-spring-cloud-version | The version of the solace-spring-cloud-bom dependency used when generating an application. Example: 1.0.0
77
-
springCloudVersion | info.x-spring-cloud-version | The version of the spring-cloud-dependencies BOM dependency used when generating an application. Example: Hoxton.RELEASE.
78
-
springCloudStreamVersion | info.x-spring-cloud-stream-version | The version of the spring-cloud-stream dependency specified in the Maven file, when generating a library. When generating an application, the spring-cloud-dependencies BOM is used instead. Example: 3.0.1.RELEASE.
79
-
username | | The client username connection property. Currently this only works with the Solace binder.
79
+
Parameter | Extension | Default | Description
80
+
----------|-----------|---------|---
81
+
actuator | | false | If true, it adds the dependencies for spring-boot-starter-web, spring-boot-starter-actuator and micrometer-registry-prometheus.
82
+
artifactId | info.x-artifact-id | project-name | The Maven artifact id.
83
+
artifactType | | application | The type of project to generate, application or library. When generating an application, the pom.xml file will contain the complete set of dependencies required to run an app, and it will contain an Application class with a main function. Otherwise the pom file will include only the dependencies required to compile a library.
84
+
binder | | kafka | The name of the binder implementation, one of kafka, rabbit or solace. Default: kafka. If you need other binders to be supported, please let us know!
85
+
groupId | info.x-group-id | com.company | The Maven group id.
86
+
host | | tcp://localhost:55555 | The host connection property. Currently this only works with the Solace binder. When other binders are used this parameter is ignored.
87
+
javaClass | info.x-java-class | Application | The name of the main class. Only used when artifactType is 'application'.
88
+
javaPackage | info.x-java-package | | The Java package of the generated classes. If not set then the classes will be in the default package.
89
+
msgVpn | | default | The message vpn connection property. Currently this only works with the Solace binder. When other binders are used this parameter is ignored.
90
+
password | | default | The client password connection property. Currently this only works with the Solace binder. When other binders are used this parameter is ignored.
91
+
reactive | | false | If true, the generated functions will use the Reactive style and use the Flux class.
92
+
solaceSpringCloudVersion | info.x-solace-spring-cloud-version | 1.0.0 | The version of the solace-spring-cloud-bom dependency used when generating an application.
93
+
springBootVersion | info.x-spring-boot-version | 2.2.6.RELEASE | The version of Spring Boot used when generating an application.
94
+
springCloudVersion | info.x-spring-cloud-version | Hoxton.SR3 | The version of the spring-cloud-dependencies BOM dependency used when generating an application.
95
+
springCloudStreamVersion | info.x-spring-cloud-stream-version | 3.0.3.RELEASE | The version of the spring-cloud-stream dependency specified in the Maven file, when generating a library. When generating an application, the spring-cloud-dependencies BOM is used instead
96
+
username | | default | The client username connection property. Currently this only works with the Solace binder. When other binders are used this parameter is ignored.
80
97
81
98
## Specification Extensions
82
99
83
100
The following specification extensions are supported. In some cases their value can be provided as a command line parameter. The 'info' prefix means that it belongs in the info section of the document.
84
101
85
-
Extension | Parameter | Description
86
-
------------|--------------|------------------
87
-
info.x-artifact-id | artifactId | The Maven artifact id.
88
-
info.x-group-id | groupId | The Maven group id.
89
-
info.x-java-class | | The name of the main class. Defaults to Application.
90
-
info.x-java-package | javaPackage | The Java package of the generated classes.
91
-
info.x-solace-spring-cloud-version | solaceSpringCloudVersion | The version of the solace-spring-cloud BOM dependency used when generating an application. Example: 1.0.0
92
-
info.x-spring-cloud-version | springCloudVersion | The version of the spring-cloud-dependencies BOM dependency used when generating an application. Example Hoxton.SR1
93
-
info.x-spring-cloud-stream-version | springCloudStreamVersion | The version of the spring-cloud-stream dependency specified in the Maven file, when generating a library. When generating an application, the spring-cloud-dependencies BOM is used instead. Example 3.0.1.RELEASE.
94
-
operation.x-scs-function-name | | This specifies the base function name to use on a publish or subscribe operation. For example, if it is set to myFunction, then the template will create functions myFunctionSupplier and/or myFunctionConsumer. If the same name is used on one subscribe operation and one publish operation, a processor function will be generated.
95
-
channel.subscription.x-scs-destination | | This overrides the destination on an incoming binding. It can be used to specify, for example, the name of a queue to subscribe to instead of a topic.
96
-
channel.subscription.x-scs-group | | This is used to specify the group property of an incoming binding.
102
+
Extension | Parameter | Default | Description
103
+
----------|-----------|---------|-------------
104
+
info.x-artifact-id | artifactId | project-name | The Maven artifact id.
105
+
info.x-group-id | groupId | com.company | The Maven group id.
106
+
info.x-java-class | javaClass | Application | The name of the main class. Only used when artifactType is 'application'.
107
+
info.x-java-package | javaPackage | | The Java package of the generated classes. If not set then the classes will be in the default package.
108
+
info.x-solace-spring-cloud-version | solaceSpringCloudVersion | 1.0.0 | The version of the solace-spring-cloud BOM dependency used when generating an application.
109
+
info.x-spring-boot-version | info.x-spring-boot-version | 2.2.6.RELEASE | The version of the Spring Boot used when generating an application.
110
+
info.x-spring-cloud-version | info.x-spring-cloud-version | Hoxton.SR3 | The version of the spring-cloud-dependencies BOM dependency used when generating an application.
111
+
info.x-spring-cloud-stream-version | springCloudStreamVersion | 3.0.3.RELEASE | The version of the spring-cloud-stream dependency specified in the Maven file, when generating a library. When generating an application, the spring-cloud-dependencies BOM is used instead.
112
+
operation.x-scs-function-name | | | This specifies the base function name to use on a publish or subscribe operation. If the same name is used on one subscribe operation and one publish operation, a processor function will be generated.
113
+
channel.subscription.x-scs-destination | | | This overrides the destination on an incoming binding. It can be used to specify, for example, the name of a queue to subscribe to instead of a topic.
114
+
channel.subscription.x-scs-group | | | This is used to specify the group property of an incoming binding.
0 commit comments