Skip to content

Commit

Permalink
Close #70: Add possibility to configure plain text/secure connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasschaefer committed Feb 4, 2022
1 parent 59245c4 commit 035c58e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,22 @@ The annotation accepts the following properties, more will be added later:

You may use the following properties (typically in application.yml) to configure the Zeebe client.

| Prefix | Property | Default | Description |
|-----------------------|-----------------------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------------|
| zeebe.client.cloud | .cluster-id | | The cluster ID when connecting to Camunda Cloud. Don't set this for a local Zeebe Broker. |
| | .client-id | | The client ID to connect to Camunda Cloud. Don't set this for a local Zeebe Broker. |
| | .client-secret | | The client secret to connect to Camunda Cloud. Don't set this for a local Zeebe Broker. |
| | .region | bru-2 | The region of the Camunda Cloud cluster. |
| | .default-request-timeout | PT20S | The request timeout used if not overridden by the command. |
| | .default-job-poll-interval | 100 | The interval which a job worker is periodically polling for new jobs. |
| | .default-job-timeout | PT5M | The timeout which is used when none is provided for a job worker. |
| | .default-message-time-to-live | PT1H | The time-to-live which is used when none is provided for a message. |
| | .default-job-worker-name | default | The name of the worker which is used when none is set for a job worker. |
| | .num-job-worker-execution-threads | 1 | The number of threads for invocation of job workers. Setting this value to 0 effectively disables subscriptions and workers. |
| | .keep-alive | PT45S | Time interval between keep alive messages sent to the gateway. |
| | .gateway-address | 0.0.0.0:26500 | The IP socket address of a gateway that the client can initially connect to. Must be in format host:port. |
| | .ca-certificate-path | default store | Path to a root CA certificate to be used instead of the certificate in the default keystore. |
| Prefix | Property | Default | Description |
|-----------------------|-----------------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| zeebe.client.cloud | .cluster-id | | The cluster ID when connecting to Camunda Cloud. Don't set this for a local Zeebe Broker. |
| | .client-id | | The client ID to connect to Camunda Cloud. Don't set this for a local Zeebe Broker. |
| | .client-secret | | The client secret to connect to Camunda Cloud. Don't set this for a local Zeebe Broker. |
| | .region | bru-2 | The region of the Camunda Cloud cluster. |
| | .use-plain-text-connection | true | Whether to use plain text or a secure connection. This property is not evaluated if connecting to Camunda Cloud because that will always use a secure connection. |
| | .default-request-timeout | PT20S | The request timeout used if not overridden by the command. |
| | .default-job-poll-interval | 100 | The interval which a job worker is periodically polling for new jobs. |
| | .default-job-timeout | PT5M | The timeout which is used when none is provided for a job worker. |
| | .default-message-time-to-live | PT1H | The time-to-live which is used when none is provided for a message. |
| | .default-job-worker-name | default | The name of the worker which is used when none is set for a job worker. |
| | .num-job-worker-execution-threads | 1 | The number of threads for invocation of job workers. Setting this value to 0 effectively disables subscriptions and workers. |
| | .keep-alive | PT45S | Time interval between keep alive messages sent to the gateway. |
| | .gateway-address | 0.0.0.0:26500 | The IP socket address of a gateway that the client can initially connect to. Must be in format host:port. |
| | .ca-certificate-path | default store | Path to a root CA certificate to be used instead of the certificate in the default keystore. |

# 🏆Advanced Topics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package info.novatec.micronaut.zeebe.client.feature;

import io.camunda.zeebe.client.ZeebeClientBuilder;
import io.micronaut.context.annotation.ConfigurationProperties;
import io.micronaut.context.annotation.Context;

Expand Down Expand Up @@ -63,6 +64,14 @@ public interface Configuration {
*/
Optional<String> getRegion();

/**
* Whether to connect with plain text or SSL/TLS. This option is not evaluated when connecting to Camunda Cloud which always uses a secure connection via SSL/TLS.
* @see ZeebeClientBuilder#usePlaintext()
*
* @return whether the connection is using plain text or SSL/TLS
*/
Optional<Boolean> getUsePlainTextConnection();

/**
* the default request timeout as ISO 8601 standard formatted String
* e.g. PT20S for a timeout of 20 seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ZeebeClient buildClient(Configuration configuration) {
protected ZeebeClientBuilder createZeebeClientBuilder(Configuration configuration) {
ZeebeClientBuilder zeebeClientBuilder = isCloudConfigurationPresent(configuration)
? createCloudClient(configuration)
: ZeebeClient.newClientBuilder().usePlaintext();
: createDefaultClient(configuration);

configuration.getDefaultRequestTimeout().ifPresent(timeout -> zeebeClientBuilder.defaultRequestTimeout(Duration.parse(timeout)));
configuration.getDefaultJobPollInterval().ifPresent(duration -> zeebeClientBuilder.defaultJobPollInterval(Duration.ofMillis(duration)));
Expand All @@ -69,10 +69,18 @@ protected ZeebeClientBuilder createCloudClient(Configuration configuration) {
return builder;
}

protected ZeebeClientBuilder createDefaultClient(Configuration configuration) {
ZeebeClientBuilder zeebeClientBuilder = ZeebeClient.newClientBuilder();
if (configuration.getUsePlainTextConnection().orElse(true)) {
zeebeClientBuilder.usePlaintext();
}

return zeebeClientBuilder;
}

protected boolean isCloudConfigurationPresent(Configuration configuration) {
return configuration.getClusterId().isPresent()
&& configuration.getClientId().isPresent()
&& configuration.getClientSecret().isPresent();
}

}

0 comments on commit 035c58e

Please sign in to comment.