第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Spring boot standalone CommandLineRunner 不會(huì)返回

Spring boot standalone CommandLineRunner 不會(huì)返回

呼喚遠(yuǎn)方 2023-03-23 15:20:34
我正在構(gòu)建一個(gè)經(jīng)典的制作人 -> rabbitmq -> 消費(fèi)者流程。所有 3 個(gè)節(jié)點(diǎn)都在單獨(dú)的 jvm 甚至單獨(dú)的主機(jī)上運(yùn)行Producer 是一個(gè) spring boot 命令行運(yùn)行器應(yīng)用程序,預(yù)計(jì)在完成生產(chǎn)后停止。消費(fèi)者應(yīng)用程序是一個(gè) spring boot web 應(yīng)用程序,它監(jiān)聽 3 個(gè) rabbitmq 隊(duì)列(2 個(gè)持久隊(duì)列綁定到直接交換,1 個(gè)非持久隊(duì)列綁定到扇出交換)我的啟動(dòng)順序如下: - 啟動(dòng) rabbitmq - 啟動(dòng)消費(fèi)者 - 啟動(dòng)生產(chǎn)者生產(chǎn)者和消費(fèi)者 amqp 依賴mvn dependency:tree[INFO] |  +- org.springframework.boot:spring-boot-starter-amqp:jar:2.1.6.RELEASE:compile[INFO] |  |  +- org.springframework:spring-messaging:jar:5.1.8.RELEASE:compile[INFO] |  |  \- org.springframework.amqp:spring-rabbit:jar:2.1.7.RELEASE:compile[INFO] |  |     +- org.springframework.amqp:spring-amqp:jar:2.1.7.RELEASE:compile[INFO] |  |     |  \- org.springframework.retry:spring-retry:jar:1.2.4.RELEASE:compile[INFO] |  |     +- com.rabbitmq:amqp-client:jar:5.4.3:compile[INFO] |  |     \- org.springframework:spring-tx:jar:5.1.8.RELEASE:compile生產(chǎn)者代碼/** * @author louis.gueye@gmail.com */@RequiredArgsConstructor@Slf4jpublic class PlatformBrokerExampleProducerJob implements CommandLineRunner {    private final AmqpTemplate template;    @Override    public void run(String... args) {        final Instant now = Instant.now();        final Instant anHourAgo = now.minus(Duration.ofHours(1));        final String directExchangeName = "careassist_queues";        final String fanoutExchangeName = "careassist_schedules_topics";        IntStream.range(0, 60).boxed().forEach(i -> {            final SensorEventDto event = SensorEventDto.builder() //                    .id(UUID.randomUUID().toString()) //                    .businessId("sens-q7ikjxk1ftik") //                    .timestamp(anHourAgo.plus(Duration.ofMinutes(i))) //                    .state(SensorState.on) //                    .build();            final String routingKey = "care.events";            template.convertAndSend(directExchangeName, routingKey, event);            log.info(">>>>>>>>>>> Sent {} to exchange {} with routing key {}", event.getId(), directExchangeName, routingKey);        });
查看完整描述

2 回答

?
神不在的星期二

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊

AMQP 客戶端有一些后臺(tái)線程。

您應(yīng)該更改main()方法以在跑步者返回后關(guān)閉應(yīng)用程序上下文...

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

它會(huì)干凈利落地關(guān)閉一切,因?yàn)樗幌?code>System.exit().


查看完整回答
反對 回復(fù) 2023-03-23
?
大話西游666

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊

PlatformBrokerClientConfiguration 綁定隊(duì)列。但我看不到任何地方可以關(guān)閉隊(duì)列。所以這可能是暫停您的實(shí)例的原因。

請?jiān)囋囘@個(gè)。

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


查看完整回答
反對 回復(fù) 2023-03-23
  • 2 回答
  • 0 關(guān)注
  • 107 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)