全域性屬性
透過在 classpath 中提供一個 properties 檔案,可以覆蓋某些全域性框架屬性。
預設屬性可在 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 中可用的執行緒數。請參閱 配置 Task Scheduler。 |
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 ),這些端點不應在應用啟動期間自動啟動。您稍後可以透過 Control Bus 按其 bean 名稱手動啟動這些端點,透過 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 版本起。 |
可以透過向 classpath 新增 /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