Class RqueueNatsAutoConfig
java.lang.Object
com.github.sonus21.rqueue.spring.boot.RqueueNatsAutoConfig
@AutoConfiguration
@AutoConfigureBefore(RqueueListenerAutoConfig.class)
@ConditionalOnClass(io.nats.client.JetStream.class)
@ConditionalOnProperty(name="rqueue.backend",
havingValue="nats")
@EnableConfigurationProperties(RqueueNatsProperties.class)
public class RqueueNatsAutoConfig
extends Object
Auto-configuration that wires a JetStream-backed
MessageBroker when
rqueue.backend=nats and the jnats client is on the classpath.
This auto-config runs before RqueueListenerAutoConfig so that the broker bean is
available for the listener container factory to consume; the existing Redis broker bean uses
@ConditionalOnMissingBean(MessageBroker.class) so it backs off when this one is present.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.nats.client.JetStreamjetStream(io.nats.client.Connection connection) io.nats.client.JetStreamManagementjetStreamManagement(io.nats.client.Connection connection) com.github.sonus21.rqueue.core.spi.MessageBrokerjetStreamMessageBroker(io.nats.client.Connection connection, io.nats.client.JetStream jetStream, io.nats.client.JetStreamManagement jetStreamManagement, com.github.sonus21.rqueue.nats.internal.NatsProvisioner natsProvisioner, RqueueNatsProperties props) io.nats.client.Connectioncom.github.sonus21.rqueue.nats.kv.NatsKvBucketValidatornatsKvBucketValidator(io.nats.client.Connection connection, RqueueNatsProperties props) Bean form of the KV-bucket validator.com.github.sonus21.rqueue.repository.MessageBrowsingRepositorynatsMessageBrowsingRepository(io.nats.client.JetStreamManagement jetStreamManagement, RqueueNatsProperties props) NATS-sideMessageBrowsingRepositorypowering the dashboard's data-explorer and queue-detail panels.com.github.sonus21.rqueue.nats.internal.NatsProvisionernatsProvisioner(io.nats.client.Connection connection, io.nats.client.JetStreamManagement jetStreamManagement, RqueueNatsProperties props) com.github.sonus21.rqueue.metrics.RqueueQueueMetricsProvidernatsRqueueQueueMetricsProvider(io.nats.client.JetStreamManagement jetStreamManagement, RqueueNatsProperties props) com.github.sonus21.rqueue.serdes.RqueueSerDesSharedRqueueSerDesfor the NATS backend.com.github.sonus21.rqueue.nats.js.NatsStreamValidatornatsStreamValidator(com.github.sonus21.rqueue.nats.internal.NatsProvisioner natsProvisioner, RqueueNatsProperties props, org.springframework.beans.factory.ObjectProvider<com.github.sonus21.rqueue.config.RqueueConfig> rqueueConfigProvider) Boot-time stream / DLQ existence guard.
-
Constructor Details
-
RqueueNatsAutoConfig
public RqueueNatsAutoConfig()
-
-
Method Details
-
natsConnection
@Bean @ConditionalOnMissingBean public io.nats.client.Connection natsConnection(RqueueNatsProperties props) throws IOException - Throws:
IOException
-
jetStream
@Bean @ConditionalOnMissingBean public io.nats.client.JetStream jetStream(io.nats.client.Connection connection) throws IOException - Throws:
IOException
-
jetStreamManagement
@Bean @ConditionalOnMissingBean public io.nats.client.JetStreamManagement jetStreamManagement(io.nats.client.Connection connection) throws IOException - Throws:
IOException
-
jetStreamMessageBroker
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.core.spi.MessageBroker.class) public com.github.sonus21.rqueue.core.spi.MessageBroker jetStreamMessageBroker(io.nats.client.Connection connection, io.nats.client.JetStream jetStream, io.nats.client.JetStreamManagement jetStreamManagement, com.github.sonus21.rqueue.nats.internal.NatsProvisioner natsProvisioner, RqueueNatsProperties props) -
natsRqueueQueueMetricsProvider
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.metrics.RqueueQueueMetricsProvider.class) public com.github.sonus21.rqueue.metrics.RqueueQueueMetricsProvider natsRqueueQueueMetricsProvider(io.nats.client.JetStreamManagement jetStreamManagement, RqueueNatsProperties props) -
natsStreamValidator
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.nats.js.NatsStreamValidator.class) public com.github.sonus21.rqueue.nats.js.NatsStreamValidator natsStreamValidator(com.github.sonus21.rqueue.nats.internal.NatsProvisioner natsProvisioner, RqueueNatsProperties props, org.springframework.beans.factory.ObjectProvider<com.github.sonus21.rqueue.config.RqueueConfig> rqueueConfigProvider) Boot-time stream / DLQ existence guard. ImplementsSmartInitializingSingletonso it runs after every@RqueueListenerhas registered withEndpointRegistrybut beforeSmartLifecycle.start()spawns the message pollers — otherwise pollers race the validator and surfacestream not found [10059]. Removes the per-publishgetStreamInforound-trip from the broker hot path. -
natsKvBucketValidator
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.nats.kv.NatsKvBucketValidator.class) public com.github.sonus21.rqueue.nats.kv.NatsKvBucketValidator natsKvBucketValidator(io.nats.client.Connection connection, RqueueNatsProperties props) Bean form of the KV-bucket validator. Other NATS beans@DependsOnthis name so it runs before they are constructed. The flag is sourced fromRqueueNatsProperties—rqueue-natsitself never readsrqueue.nats.*keys directly. -
natsSerDes
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.serdes.RqueueSerDes.class) public com.github.sonus21.rqueue.serdes.RqueueSerDes natsSerDes()SharedRqueueSerDesfor the NATS backend. Backed by Jackson with the same configuration as the rest of rqueue (FAIL_ON_UNKNOWN_PROPERTIES=false, auto-detected modules) so values written to KV buckets are readable vianats kv get. -
natsProvisioner
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.nats.internal.NatsProvisioner.class) @DependsOn("natsKvBucketValidator") public com.github.sonus21.rqueue.nats.internal.NatsProvisioner natsProvisioner(io.nats.client.Connection connection, io.nats.client.JetStreamManagement jetStreamManagement, RqueueNatsProperties props) throws IOException - Throws:
IOException
-
natsMessageBrowsingRepository
@Bean @ConditionalOnMissingBean(com.github.sonus21.rqueue.repository.MessageBrowsingRepository.class) public com.github.sonus21.rqueue.repository.MessageBrowsingRepository natsMessageBrowsingRepository(io.nats.client.JetStreamManagement jetStreamManagement, RqueueNatsProperties props) NATS-sideMessageBrowsingRepositorypowering the dashboard's data-explorer and queue-detail panels. Maps Redis-style queue names to JetStream streams and returns actual message counts from the broker. JetStream KV doesn't model arbitrary keyed reads, so throwsBackendCapabilityException(mapped to HTTP 501 byRqueueWebExceptionAdvice).
-