Class DirectMessageListenerContainer

    • Field Detail

      • consumers

        protected final List<org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer.SimpleConsumer> consumers
    • Constructor Detail

      • DirectMessageListenerContainer

        public DirectMessageListenerContainer​(ConnectionFactory connectionFactory)
        Create an instance with the provided connection factory.
        Parameters:
        connectionFactory - the connection factory.
    • Method Detail

      • setConsumersPerQueue

        public void setConsumersPerQueue​(int consumersPerQueue)
        Each queue runs in its own consumer; set this property to create multiple consumers for each queue. If the container is already running, the number of consumers per queue will be adjusted up or down as necessary.
        Parameters:
        consumersPerQueue - the consumers per queue.
      • setTaskScheduler

        public void setTaskScheduler​(TaskScheduler taskScheduler)
        Set the task scheduler to use for the task that monitors idle containers and failed consumers.
        Parameters:
        taskScheduler - the scheduler.
      • setMonitorInterval

        public void setMonitorInterval​(long monitorInterval)
        Set how often to run a task to check for failed consumers and idle containers.
        Parameters:
        monitorInterval - the interval; default 10000 but it will be adjusted down to the smallest of this, idleEventInterval / 2 (if configured) or failedDeclarationRetryInterval.
      • setMissingQueuesFatal

        public final void setMissingQueuesFatal​(boolean missingQueuesFatal)
        If all of the configured queue(s) are not available on the broker, this setting determines whether the condition is fatal. When true, and the queues are missing during startup, the context refresh() will fail.

        When false, the condition is not considered fatal and the container will continue to attempt to start the consumers.

        Defaults to false for this container.

        Overrides:
        setMissingQueuesFatal in class AbstractMessageListenerContainer
        Parameters:
        missingQueuesFatal - the missingQueuesFatal to set.
        See Also:
        AbstractMessageListenerContainer.setAutoDeclare(boolean)
      • setMessagesPerAck

        public void setMessagesPerAck​(int messagesPerAck)
        Set the number of messages to receive before acknowledging (success). A failed message will short-circuit this counter.
        Parameters:
        messagesPerAck - the number of messages.
        See Also:
        setAckTimeout(long)
      • setAckTimeout

        public void setAckTimeout​(long ackTimeout)
        An approximate timeout; when messagesPerAck is greater than 1, and this time elapses since the last ack, the pending acks will be sent either when the next message arrives, or a short time later if no additional messages arrive. In that case, the actual time depends on the monitorInterval.
        Parameters:
        ackTimeout - the timeout in milliseconds (default 20000);
        See Also:
        setMessagesPerAck(int)
      • findIdleConsumer

        protected int findIdleConsumer()
        When adjusting down, return a consumer that can be canceled. Called while synchronized on consumersMonitor.
        Returns:
        the consumer index or -1 if non idle.
        Since:
        2.0.6
      • actualStart

        protected void actualStart()
      • checkConnect

        protected void checkConnect()
      • doRedeclareElementsIfNecessary

        protected void doRedeclareElementsIfNecessary()
      • processMonitorTask

        protected void processMonitorTask()
        Subclasses can override this to take additional actions when the monitor task runs.
      • consumerRemoved

        protected void consumerRemoved​(org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer.SimpleConsumer consumer)
        Called whenever a consumer is removed.
        Parameters:
        consumer - the consumer.