是否可以对 PubSub 订阅者使用 spring ThreadPoolTaskExecutor?
Is it possible to use spring ThreadPoolTaskExecutor for PubSub subscribers?
关于并发的部分here uses ExecutorProivder
, but since my project is in spring-boot
I am not sure if it would be fine to use this for managing threads when there already exists ThreadPoolTaskExecutor。是否可以为订阅者使用这些由 spring 管理的线程?如果不是,可以使用 ExecutorProivder
还是以后会出问题?我知道 google pub-sub 存在 spring 抽象,但我不想使用它。
您可以提供自己的执行程序(例如,提供您的 Spring 管理的线程)。您可以通过将 getExecutor() 方法覆盖为 return 您自己的计划执行程序服务来实现,例如 this example.
您也可以考虑按照 the example in the concurrency docs you referenced 创建一个专门用于 PubSub 订阅的单独执行器,以实现更多线程隔离。
两种方法都可以。
关于并发的部分here uses ExecutorProivder
, but since my project is in spring-boot
I am not sure if it would be fine to use this for managing threads when there already exists ThreadPoolTaskExecutor。是否可以为订阅者使用这些由 spring 管理的线程?如果不是,可以使用 ExecutorProivder
还是以后会出问题?我知道 google pub-sub 存在 spring 抽象,但我不想使用它。
您可以提供自己的执行程序(例如,提供您的 Spring 管理的线程)。您可以通过将 getExecutor() 方法覆盖为 return 您自己的计划执行程序服务来实现,例如 this example.
您也可以考虑按照 the example in the concurrency docs you referenced 创建一个专门用于 PubSub 订阅的单独执行器,以实现更多线程隔离。
两种方法都可以。