全域性屬性
透過在類路徑中提供屬性檔案,可以覆蓋某些全域性框架屬性。
預設屬性可在 org.springframework.integration.context.IntegrationProperties 類中找到。以下列表顯示了預設值:
spring.integration.channels.autoCreate=true (1)
spring.integration.channels.maxUnicastSubscribers=0x7fffffff (2)
spring.integration.channels.maxBroadcastSubscribers=0x7fffffff (3)
spring.integration.taskScheduler.poolSize=10 (4)
spring.integration.messagingTemplate.throwExceptionOnLateReply=false (5)
spring.integration.readOnly.headers= (6)
spring.integration.endpoints.noAutoStartup= (7)
spring.integration.channels.error.requireSubscribers=true (8)
spring.integration.channels.error.ignoreFailures=true (9)
spring.integration.endpoints.defaultTimeout=30000 (10)
| 1 | 當為 true 時,如果應用程式上下文中未明確找到 input-channel 例項,它們會自動宣告為 DirectChannel 例項。 |
| 2 | 設定例如 DirectChannel 允許的預設訂閱者數量。它可用於避免無意中將多個端點訂閱到同一個通道。您可以透過設定 max-subscribers 屬性來覆蓋各個通道上的此設定。 |
| 3 | 此屬性提供了例如 PublishSubscribeChannel 允許的預設訂閱者數量。它可用於避免無意中將超出預期數量的端點訂閱到同一個通道。您可以透過設定 max-subscribers 屬性來覆蓋各個通道上的此設定。 |
| 4 | 預設 taskScheduler bean 中可用的執行緒數。請參閱 配置任務排程器。 |
| 5 | 當 true 時,當閘道器不期望回覆(因為傳送執行緒已超時或已收到回覆)時,到達網關回復通道的訊息會丟擲異常。 |
| 6 | 一個逗號分隔的訊息頭名稱列表,在頭複製操作期間不應填充到 Message 例項中。此列表由 DefaultMessageBuilderFactory bean 使用,並傳播到透過 MessageBuilder(參見 MessageBuilder 輔助類)構建訊息時使用的 IntegrationMessageHeaderAccessor 例項(參見 MessageHeaderAccessor API)。預設情況下,在訊息構建期間,只複製 MessageHeaders.ID 和 MessageHeaders.TIMESTAMP。自版本 4.3.2 起。 |
| 7 | 一個逗號分隔的 AbstractEndpoint bean 名稱模式(xxx*、xxx、*xxx 或 xxx*yyy)列表,這些模式不應在應用程式啟動期間自動啟動。您可以稍後透過 控制匯流排、透過 SmartLifecycleRoleController(參見 端點角色)按其角色,或透過 Lifecycle bean 注入,手動啟動這些端點。您可以透過指定 auto-startup XML 註解或 autoStartup 註解屬性,或透過在 bean 定義中呼叫 AbstractEndpoint.setAutoStartup() 來明確覆蓋此全域性屬性的效果。自版本 4.3.12 起。 |
| 8 | 一個布林標誌,指示預設全域性 errorChannel 必須使用 requireSubscribers 選項進行配置。自版本 5.4.3 起。有關更多資訊,請參見 錯誤處理。 |
| 9 | 一個布林標誌,指示預設全域性 errorChannel 必須忽略分派錯誤並將訊息傳遞給下一個處理程式。自版本 5.5 起。 |
| 10 | 端點中請求和回覆超時的預設毫秒數。預設值為 30 秒,以避免無限期阻塞。可以配置為負值以恢復端點中的無限阻塞行為。自版本 6.2 起。 |
這些屬性可以透過將 /META-INF/spring.integration.properties 檔案新增到類路徑或為 org.springframework.integration.context.IntegrationProperties 例項新增 IntegrationContextUtils.INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME bean 來覆蓋。您無需提供所有屬性 — 只需提供您想要覆蓋的屬性。
從版本 5.1 開始,當 org.springframework.integration 類別的 DEBUG 邏輯級別開啟時,所有合併的全域性屬性將在應用程式上下文啟動後列印到日誌中。輸出如下所示:
Spring Integration global properties:
spring.integration.endpoints.noAutoStartup=fooService*
spring.integration.taskScheduler.poolSize=20
spring.integration.channels.maxUnicastSubscribers=0x7fffffff
spring.integration.channels.autoCreate=true
spring.integration.channels.maxBroadcastSubscribers=0x7fffffff
spring.integration.readOnly.headers=
spring.integration.messagingTemplate.throwExceptionOnLateReply=true
spring.integration.endpoints.defaultTimeout=30000