Git Product home page Git Product logo

Comments (5)

lukaseckert avatar lukaseckert commented on May 2, 2024

Some notes on the setup:

That "reporting-service.SnapshotSync" queue is started and stopped later by the application. It is running only during a certain phase of the application lifetime. This is done by auto-wiring the RabbitListenerEndpointRegistry and calling start()/stop() as in the following snippet:

endpointRegistry.getListenerContainer(RabbitConfig.LISTENER_ID_SNAPSHOT_SYNC).start()
// ...
endpointRegistry.getListenerContainer(RabbitConfig.LISTENER_ID_SNAPSHOT_SYNC).stop()

The problematic queue is an non-auto-startup, exclusive queue as defined by

@RabbitListener(
    queues = "#{snapshotSyncQueue.name}",
    autoStartup = "false",
    id = RabbitConfig.LISTENER_ID_SNAPSHOT_SYNC,
    exclusive = true
)
public class SnapshotSyncRabbitController {
// ...

from spring-amqp.

artembilan avatar artembilan commented on May 2, 2024

The fix you are mentioning has not been released yet: #2492.

Probably this b98847c or this 95631d8.

It would be great if you can test your project against 2.4.15-SNAPSHOT. It is going to be released in a couple weeks: https://calendar.spring.io/

from spring-amqp.

lukaseckert avatar lukaseckert commented on May 2, 2024

Hi @artembilan ,
thanks for your response, but unfortunately using the 2.4.15-SNAPSHOT versions of spring-amqp and spring-rabbit does not fix the issue. I think it is not related to the forceStop() flag, which I already tried to set on my own via a ContainerCustomizer bean.
The error message stays the same:
Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000ms: [org.springframework.amqp.rabbit.config.internalRabbitListenerEndpointRegistry] [stop(), DefaultLifecycleProcessor.java:384]

I double-checked the classpath of the running app to ensure it is using the snapshot version:

.gradle\caches\modules-2\files-2.1\org.springframework.amqp\spring-rabbit\2.4.15-SNAPSHOT\b3a16ac4af72a8cc4aca73236df4d90cde140442\spring-rabbit-2.4.15-SNAPSHOT.jar
.gradle\caches\modules-2\files-2.1\org.springframework.amqp\spring-amqp\2.4.15-SNAPSHOT\389a7a17bb5c73e1ed4cc09d11ac427a6f22845\spring-amqp-2.4.15-SNAPSHOT.jar

I know it is a long text 😉 But I guess the problem is the same as in my original issue conclusion:
In AbstractMessageListenerContainer.java:1370 the method can return without executing a given (non-nulll) shutdown callback, therefore missing to decrease a countdown latch in the DefaultLifecycleProcessor.

from spring-amqp.

lukaseckert avatar lukaseckert commented on May 2, 2024

This is a minimal sample app that reproduces the issue with 2.4.15-SNAPSHOT. Just start and then stop the application to see the issue:

DemoApplication.java

@SpringBootApplication
@EnableRabbit
public class DemoApplication {

    @Bean
    public Queue queue1() {
        return new Queue("reporting-service.queue1", false);
    }

    @Bean
    public Queue queue2() {
        return new Queue("reporting-service.queue2", false);
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

DemoRabbitController.java

@Controller
public class DemoRabbitController {

    @RabbitListener(queues = "#{queue1.name}")
    public void receive1(String message) {
        System.out.println(message);
    }

    @RabbitListener(queues = "#{queue2.name}", autoStartup = "false")
    public void receive2(String message) {
        System.out.println(message);
    }

}

Result
The graceful shutdown hangs for 30sec and then prints the Failed to shut down 1 bean error before the process exits:

...
2023-08-09 10:21:03.267  INFO 6860 --- [           main] o.s.amqp.rabbit.core.RabbitAdmin         : Auto-declaring a non-durable, auto-delete, or exclusive Queue (reporting-service.queue1) durable:false, auto-delete:false, exclusive:false. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
2023-08-09 10:21:03.267  INFO 6860 --- [           main] o.s.amqp.rabbit.core.RabbitAdmin         : Auto-declaring a non-durable, auto-delete, or exclusive Queue (reporting-service.queue2) durable:false, auto-delete:false, exclusive:false. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
2023-08-09 10:21:03.302  INFO 6860 --- [           main] c.example.shutdownhang.DemoApplication   : Started DemoApplication in 1.67 seconds (JVM running for 2.138)
// --------  triggered application stop via InteliJ --------
2023-08-09 10:21:13.318  INFO 6860 --- [ntContainer#0-2] o.s.a.r.l.SimpleMessageListenerContainer : Waiting for workers to finish.
2023-08-09 10:21:14.319  INFO 6860 --- [ntContainer#0-2] o.s.a.r.l.SimpleMessageListenerContainer : Successfully waited for workers to finish.
2023-08-09 10:21:43.320  INFO 6860 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000ms: [org.springframework.amqp.rabbit.config.internalRabbitListenerEndpointRegistry]

Process finished with exit code 130

from spring-amqp.

garyrussell avatar garyrussell commented on May 2, 2024

Confirmed regression; probably caused by 1fdfe65

from spring-amqp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.