1
當使用基於XML的配置service-activator
可以排除method
如下:服務激活就沒有辦法在Spring集成的Java配置/ DSL
<service-activator input-channel="incomingCustomerChannel" output-channel="outgoingCustomerChannel" ref="customerService" />
這將導致SI框架,選擇customerService
目標方法基於有效載荷。我如何使用DSL和Java配置實現相同的功能?
目前我有以下:
@Bean
public IntegrationFlow customerRequestFlow(ConnectionFactory connectionFactory) {
return IntegrationFlows.from((MessagingGateways g) -> g.jms(connectionFactory)
.correlationKey("JmsCorrelationID")
.destination("customer_incoming.queue"))
.handle("customerService", "addCustomer")
.get();
}
服務活化劑定義爲:
@Component
public class customerService {
@ServiceActivator
public AddCustomerResponse addCustomer(AddCustomerRequest addCustomerRequest) {
// add customer
}
}
我已經擴展了活化劑添加deleteCustomer
方法如下:
@Component
public class customerService {
@ServiceActivator
public AddCustomerResponse addCustomer(AddCustomerRequest request) {
// add customer
}
@ServiceActivator
public DeleteCustomerResponse deleteCustomer(DeleteCustomerRequest request) {
// delete customer
}
}
我不能簡單地從中刪除 as methodName
是強制性的。是否有可能在Java config/DSL中實現這一點?
我不知道如何轉換,但您可以通過使用'PayloadTypeRouter'實現相同的行爲,這是在[Spring Integration DSL]中預定義的(https://github.com/spring-projects/彈簧集成的Java-DSL /維基/ Spring的集成的Java-DSL-參考#消息路由器)。 – Nicolas