W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
從2.0版開始,Spring Cloud Stream支持通過Actuator端點(diǎn)進(jìn)行綁定的可視化和控制。
從2.0版執(zhí)行器開始,并且web是可選的,您必須首先添加web依賴項(xiàng)之一,然后手動添加執(zhí)行器依賴項(xiàng)。以下示例說明如何為Web框架添加依賴項(xiàng):
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
以下示例顯示如何為WebFlux框架添加依賴項(xiàng):
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency>
您可以添加執(zhí)行器依賴項(xiàng),如下所示:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
要在Cloud Foundry中運(yùn)行Spring Cloud Stream 2.0應(yīng)用程序,必須將
spring-boot-starter-web
和spring-boot-starter-actuator
添加到類路徑中。否則,由于運(yùn)行狀況檢查失敗,該應(yīng)用程序?qū)o法啟動。
您還必須通過設(shè)置以下屬性來啟用bindings
執(zhí)行器端點(diǎn):--management.endpoints.web.exposure.include=bindings
。
一旦滿足這些先決條件。應(yīng)用程序啟動時(shí),您應(yīng)該在日志中看到以下內(nèi)容:
: Mapped "{[/actuator/bindings/{name}],methods=[POST]. . . : Mapped "{[/actuator/bindings],methods=[GET]. . . : Mapped "{[/actuator/bindings/{name}],methods=[GET]. . .
要顯示當(dāng)前綁定,請?jiān)L問以下URL:http://<host>:<port>/actuator/bindings
或者,要查看單個(gè)綁定,請?jiān)L問類似于以下內(nèi)容的URL之一:http://<host>:<port>/actuator/bindings/myBindingName
您還可以通過發(fā)布到相同的URL來停止,開始,暫停和恢復(fù)單個(gè)綁定,同時(shí)提供一個(gè)state
作為JSON的參數(shù),如以下示例所示:
curl -d'{“ state”:“ STOPPED”}'-H“內(nèi)容類型:應(yīng)用程序/ json” -X POST http:// <主機(jī)>:<port> / actuator / bindings / myBindingName curl -d'{ “ state”:“ STARTED”}'-H“內(nèi)容類型:application / json” -X POST http:// <host>:<port> / actuator / bindings / myBindingName curl -d'{“ state”:“ PAUSED“}'-H”內(nèi)容類型:application / json“ -X POST http:// <host>:<port> / actuator / bindings / myBindingName curl -d'{” state“:” RESUMED“}'- H“內(nèi)容類型:應(yīng)用程序/ json” -X POST http:// <主機(jī)>:<端口> / actuator / bindings / myBindingName
PAUSED
和RESUMED
僅在相應(yīng)的活頁夾及其基礎(chǔ)技術(shù)支持時(shí)起作用。否則,您會在日志中看到警告消息。當(dāng)前,只有Kafka活頁夾支持PAUSED
和RESUMED
狀態(tài)。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: