Class AceMqAutoConfiguration

java.lang.Object
org.acemq.spring.boot.AceMqAutoConfiguration

@AutoConfiguration @ConditionalOnClass(org.acemq.amqp.core.AceMq.class) @ConditionalOnProperty(prefix="acemq", name="enabled", havingValue="true", matchIfMissing=true) @EnableConfigurationProperties(AceMqProperties.class) public class AceMqAutoConfiguration extends Object
Wires AceMQ from acemq.*.

What an application gets: an AceMq connection, the codec named by acemq.format, telemetry through Micrometer when a registry is present, the declared topology applied once, and AceListener methods consuming.

The health indicator is not here. It lives in acemq-spring-boot-health-boot3 and acemq-spring-boot-health-boot4, one per Spring Boot line, because Boot 4 moved the health contributor API to a different package in a different artifact. Both are on the classpath when the starter is used, and exactly one of them ever matches. This module itself compiles and runs unchanged on both lines.

Every bean is @ConditionalOnMissingBean. Defining your own AceMq bean -- two connections, a transport this starter does not know about, a wrapper -- replaces the one here and keeps the listeners, the topology and the health indicator, because those take the connection as a dependency rather than creating it.

  • Constructor Details

    • AceMqAutoConfiguration

      public AceMqAutoConfiguration()
  • Method Details

    • aceMqConnectionDetails

      @Bean @ConditionalOnMissingBean(AceMqConnectionDetails.class) public AceMqConnectionDetails aceMqConnectionDetails(AceMqProperties properties)
      Where the broker is, read from acemq.*. Docker Compose and a Testcontainers @ServiceConnection each register their own bean of this type, which replaces this one.
      Parameters:
      properties - the acemq.* configuration
      Returns:
      the details
    • aceMqConnectionConfig

      @Bean @ConditionalOnMissingBean public org.acemq.amqp.transport.ConnectionConfig aceMqConnectionConfig(AceMqProperties properties, AceMqConnectionDetails details, org.springframework.core.env.Environment environment)
      The connection configuration, separately from the connection, so an application can see and override it without taking over connecting.
      Parameters:
      properties - the acemq.* configuration
      details - where the broker is
      environment - used only for spring.application.name
      Returns:
      the configuration
    • aceMqCodec

      @Bean @ConditionalOnMissingBean public org.acemq.amqp.api.Codec aceMqCodec(AceMqProperties properties)
      The default codec.
      Parameters:
      properties - the acemq.* configuration
      Returns:
      the codec named by acemq.format
    • aceMq

      @Bean(destroyMethod="close") @ConditionalOnMissingBean public org.acemq.amqp.core.AceMq aceMq(org.acemq.amqp.transport.ConnectionConfig config, org.acemq.amqp.api.Telemetry telemetry, org.acemq.amqp.api.Codec codec)
      The connection.

      destroyMethod closes it: the context owns the connection, and an application that has to remember to close it will forget in exactly the tests that create a context per class.

      Parameters:
      config - the connection configuration
      telemetry - telemetry
      codec - the default codec
      Returns:
      the connection
    • aceMqTopologyInitializer

      @Bean @ConditionalOnMissingBean public AceMqTopologyInitializer aceMqTopologyInitializer(org.acemq.amqp.core.AceMq aceMq, AceMqProperties properties)
      Applies the declared topology. Does nothing when nothing is declared.

      The bean exists either way rather than hiding behind a condition on the properties: a list under acemq.topology.queues is bound as indexed keys, which @ConditionalOnProperty cannot see, so the condition would be wrong in the one direction that matters -- silently skipping a topology somebody declared.

      Parameters:
      aceMq - the connection
      properties - the acemq.* configuration
      Returns:
      the initializer
    • aceListenerRegistry

      @Bean @ConditionalOnMissingBean public AceListenerRegistry aceListenerRegistry(org.acemq.amqp.core.AceMq aceMq, AceMqProperties properties)
      The listener registry, which starts and stops the annotated methods.

      It is handed the declared topology and its apply mode. Queues under acemq.topology.queues are not asked about, because the topology is applied before any listener starts and in validate mode a missing one has already failed the startup; a dry run creates nothing, so then every queue is asked about. A listener that declares its own queue declares it in the same mode, and has to agree with the topology when both declare it.

      Parameters:
      aceMq - the connection
      properties - the acemq.* configuration
      Returns:
      the registry
    • aceListenerAnnotationBeanPostProcessor

      @Bean @ConditionalOnMissingBean public static AceListenerAnnotationBeanPostProcessor aceListenerAnnotationBeanPostProcessor(org.springframework.beans.factory.ObjectProvider<AceListenerRegistry> registry, AceMqProperties properties)
      The post-processor that finds AceListener methods.

      Static, which Spring requires of a BeanPostProcessor factory method: a non-static one would instantiate this configuration class -- and with it the connection -- before post-processing began.

      Parameters:
      registry - the registry to register endpoints with, resolved lazily
      properties - the acemq.* configuration
      Returns:
      the post-processor