Class RabbitMqConfiguration

java.lang.Object
com.minicrm.mini_crm_api.config.RabbitMqConfiguration

@Configuration @EnableRabbit public class RabbitMqConfiguration extends Object
Configures the neccessary RabbitMQ exhanges, queues and bindings
  • Field Details

  • Constructor Details

    • RabbitMqConfiguration

      public RabbitMqConfiguration()
  • Method Details

    • singleListenerFactory

      @Bean public org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory singleListenerFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory, org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer configurer)
      This is the default factory for listeners that consume one message at a time.
      Parameters:
      connectionFactory - The RabbitMQ connection factory.
      configurer - The configurer to apply default settings.
      Returns:
      A SimpleRabbitListenerContainerFactory configured for single message
    • batchListenerFactory

      @Bean public org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory batchListenerFactory(org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer configurer, org.springframework.amqp.rabbit.connection.ConnectionFactory connectionFactory)
      This is the specialized factory for listeners that consume messages in batches. batch size and timeout are configured in application.properties
      Parameters:
      configurer - The configurer to apply default settings.
      connectionFactory - The RabbitMQ connection factory.
      Returns:
      A SimpleRabbitListenerContainerFactory configured for batch message consumption.
    • messageConverter

      @Bean public org.springframework.amqp.support.converter.MessageConverter messageConverter()
      Defines a MessageConverter bean that will be used by RabbitTemplate and RabbitListener to serialize and deserialize message payloads.

      By defining this bean, we are telling Spring to use JSON for all our message payloads, which allows us to send complex DTOs over the message queue.

      Returns:
      A Jackson2JsonMessageConverter instance.