Package io.micronaut.pulsar.config
Class DefaultPulsarClientConfiguration
java.lang.Object
io.micronaut.pulsar.config.AbstractPulsarConfiguration
io.micronaut.pulsar.config.DefaultPulsarClientConfiguration
- All Implemented Interfaces:
PulsarClientConfiguration
@ConfigurationProperties("pulsar")
@Requires("pulsar") @Requires(missingBeans=PulsarClientConfiguration.class)
public final class DefaultPulsarClientConfiguration
extends AbstractPulsarConfiguration
implements PulsarClientConfiguration
Default properties holder for Pulsar client configuration.
- Since:
- 1.0
- Author:
- Haris Secic
-
Field Summary
Fields inherited from class io.micronaut.pulsar.config.AbstractPulsarConfiguration
DEFAULT_BOOTSTRAP_SERVER, DEFAULT_PULSAR_AUTHENTICATION, DEFAULT_PULSAR_MESSAGING_PORT, DEFAULT_SERVER_HOST_ADDRESS, PREFIX, TENANT_NAME_VALIDATOR, TOPIC_NAME_PATTERN_VALIDATOR, TOPIC_NAME_VALIDATOR
-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultPulsarClientConfiguration
(io.micronaut.context.env.Environment environment, @Nullable org.apache.pulsar.client.api.ServiceUrlProvider serviceUrlProvider) Constructs the default Pulsar Client configuration. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pulsar.client.api.Authentication
int
Useful for avoiding hard coding tenant name into every annotation value for producers, consumers, or readers.Must be set for usage with the OAuth2 authentication.Optional<org.apache.pulsar.client.api.ServiceUrlProvider>
Optional provider for Pulsar services URL.Ciphers like TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256.Protocols like TLSv1.3, TLSv1.2.Useful in development environment for using with local host or such.void
setAuthenticationJwt
(@Nullable String authenticationJwt) void
setDefaultMaxRetryDlq
(int defaultMaxRetryDlq) If not set defaults to 16 (Pulsar library default).void
setDefaultTenant
(String defaultTenant) Use in combination with ${tenant} placeholder inPulsarConsumer.topic()
,PulsarConsumer.topics()
,PulsarConsumer.topicsPattern()
,PulsarReader.topic()
,PulsarProducer.topic()
to avoid hardcoding tenant name into source code through mentioned annotations.void
setIoThreads
(Integer ioThreads) void
setListenerThreads
(Integer listenerThreads) void
setOauthAudience
(String oauthAudience) void
setOauthCredentialsUrl
(URL oauthCredentialsUrl) void
setOauthIssuerUrl
(URL oauthIssuerUrl) void
setServiceUrl
(@Nullable String serviceUrl) void
setSslProvider
(String sslProvider) Defaults to default JVM provider.void
setTlsAllowInsecureConnection
(Boolean tlsAllowInsecureConnection) void
setTlsCertFilePath
(String tlsCertFilePath) void
setTlsCiphers
(Set<String> tlsCiphers) void
setTlsProtocols
(Set<String> tlsProtocols) void
setTlsTrustStorePassword
(String tlsTrustStorePassword) void
setTlsTrustStorePath
(String tlsTrustStorePath) void
setTlsVerifyHostname
(Boolean tlsVerifyHostname) void
setUseDeadLetterQueue
(Boolean useDeadLetterQueue) If not set defaults to true which means that after max number of retries failed message is sent to DLQ and won't be resent again.Methods inherited from class io.micronaut.pulsar.config.AbstractPulsarConfiguration
getConfig
-
Constructor Details
-
DefaultPulsarClientConfiguration
protected DefaultPulsarClientConfiguration(io.micronaut.context.env.Environment environment, @Nullable @PulsarServiceUrlProvider @Nullable org.apache.pulsar.client.api.ServiceUrlProvider serviceUrlProvider) Constructs the default Pulsar Client configuration.- Parameters:
environment
- EnvironmentserviceUrlProvider
- Pulsars service URL provider
-
-
Method Details
-
getIoThreads
- Specified by:
getIoThreads
in interfacePulsarClientConfiguration
- Returns:
- Number of threads to allow for Pulsar library.
-
setIoThreads
- Parameters:
ioThreads
- Number of threads to use with read operations
-
getListenerThreads
- Specified by:
getListenerThreads
in interfacePulsarClientConfiguration
- Returns:
- Number of threads to allow for listeners from IO threads defined for Pulsar library
-
setListenerThreads
- Parameters:
listenerThreads
- Number of threads to use with message example.java.listeners.
-
setAuthenticationJwt
-
getSslProvider
- Specified by:
getSslProvider
in interfacePulsarClientConfiguration
- Returns:
- SSL provider if any for Pulsar to client communication encryption
-
setTlsTrustStorePath
-
getTlsTrustStorePath
- Specified by:
getTlsTrustStorePath
in interfacePulsarClientConfiguration
-
setTlsTrustStorePassword
-
getTlsTrustStorePassword
- Specified by:
getTlsTrustStorePassword
in interfacePulsarClientConfiguration
- Returns:
- trust store password if any, trust stores don't contain any sensitive information but often work better with password in Java context.
-
setTlsCertFilePath
-
getTlsCertFilePath
- Specified by:
getTlsCertFilePath
in interfacePulsarClientConfiguration
- Returns:
- TLS certificate file path if any for TLS communication between Pulsar and clients.
-
setTlsVerifyHostname
-
getTlsVerifyHostname
Description copied from interface:PulsarClientConfiguration
Useful in development environment for using with local host or such.- Specified by:
getTlsVerifyHostname
in interfacePulsarClientConfiguration
- Returns:
- Whether to verify TLS certificate host or not.
-
setTlsAllowInsecureConnection
-
getTlsAllowInsecureConnection
- Specified by:
getTlsAllowInsecureConnection
in interfacePulsarClientConfiguration
- Returns:
- Allow insecure connection when TLS certificate is set or not.
-
setTlsCiphers
-
getTlsCiphers
Description copied from interface:PulsarClientConfiguration
Ciphers like TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256.- Specified by:
getTlsCiphers
in interfacePulsarClientConfiguration
- Returns:
- Permitted ciphers for TLS.
-
setTlsProtocols
-
getTlsProtocols
Description copied from interface:PulsarClientConfiguration
Protocols like TLSv1.3, TLSv1.2.- Specified by:
getTlsProtocols
in interfacePulsarClientConfiguration
- Returns:
- Permitted protocols for TLS.
-
setSslProvider
Defaults to default JVM provider.- Parameters:
sslProvider
- The name of the security provider used for SSL connections.
-
getServiceUrl
- Specified by:
getServiceUrl
in interfacePulsarClientConfiguration
- Returns:
- Apache Pulsar cluster address (IP or domain or hostname + port)
-
setServiceUrl
- Parameters:
serviceUrl
- URL to Pulsar cluster
-
getServiceUrlProvider
Description copied from interface:PulsarClientConfiguration
Optional provider for Pulsar services URL.- Specified by:
getServiceUrlProvider
in interfacePulsarClientConfiguration
- Returns:
- Optional bean for fetching Pulsar services URLs
-
getAuthentication
public org.apache.pulsar.client.api.Authentication getAuthentication()- Specified by:
getAuthentication
in interfacePulsarClientConfiguration
- Returns:
- Authentication method for pulsar clients
-
getOauthAudience
Must be set for usage with the OAuth2 authentication.- Returns:
- String representing client application willing to listen to
-
setOauthAudience
- Parameters:
oauthAudience
- OAuth2 audience
-
getOauthCredentialsUrl
-
setOauthCredentialsUrl
- Parameters:
oauthCredentialsUrl
- URL or a path to a file containing client id, client secret, and such for OAuth2 client application.
-
getOauthIssuerUrl
-
setOauthIssuerUrl
- Parameters:
oauthIssuerUrl
- URL of the OAuth2 Token issuer
-
getUseDeadLetterQueue
-
setUseDeadLetterQueue
If not set defaults to true which means that after max number of retries failed message is sent to DLQ and won't be resent again.- Parameters:
useDeadLetterQueue
- Use DLQ for Pulsar Consumers by default or not.
-
getDefaultMaxRetryDlq
public int getDefaultMaxRetryDlq() -
setDefaultMaxRetryDlq
public void setDefaultMaxRetryDlq(int defaultMaxRetryDlq) If not set defaults to 16 (Pulsar library default).#useDeadLetterQueue
must be enabled or else this value is ignored.- Parameters:
defaultMaxRetryDlq
- Default max number of retries before sending message to DLQ for all consumers.
-
getDefaultTenant
Description copied from interface:PulsarClientConfiguration
Useful for avoiding hard coding tenant name into every annotation value for producers, consumers, or readers.- Specified by:
getDefaultTenant
in interfacePulsarClientConfiguration
- Returns:
- Default tenant name if any.
-
setDefaultTenant
Use in combination with ${tenant} placeholder inPulsarConsumer.topic()
,PulsarConsumer.topics()
,PulsarConsumer.topicsPattern()
,PulsarReader.topic()
,PulsarProducer.topic()
to avoid hardcoding tenant name into source code through mentioned annotations.This property will be ignored if multi-tenancy module is enabled.
- Parameters:
defaultTenant
- Default Apache Pulsar tenant name to apply on dynamic topic names.
-