2017-04-01 148 views
2

我們在XML中具有下面的工作配置,並正試圖轉換爲DSL。不確定它們是否相同,也嘗試使用inboundAdapter。但是,我無法弄清楚如何在那裏設置併發相關值。有人可以建議他們是否在DSL中使用了這些參數中的messageDrivenChannelAdapter或inboundAdapter?Spring集成JMS DSL

<jms:message-driven-channel-adapter 
id="inputChannelAdapter" 
channel="inputChannel" 
destination-name="inboundQueueName" 
connection-factory="cachingConnectionFactory" 
acknowledge="transacted" 
header-mapper="defaultJmsHeaderMapper" 
error-channel="errorChannel" 
concurrent-consumers="10" 
max-concurrent-consumers="20"/> 



@Bean 
public IntegrationFlow jmsInboundFlow() { 
    return IntegrationFlows 
      .from(Jms.messageDrivenChannelAdapter(cachingConnectionFactory) 
        .configureListenerContainer(c -> { 
         DefaultMessageListenerContainer container = c.get(); 
         container.setSessionTransacted(true); 
         container.setSessionAcknowledgeModeName(""); 
         container.setMaxConcurrentConsumers(30); 
         container.setConcurrentConsumers(20); 
        }) 
        .destination(inboundQueueName).headerMapper(defaultJmsHeaderMapper) 
        .errorChannel("errorChannel")) 
      .channel(MessageChannels.queue("inputChannel")) 
      .get(); 
} 


@Bean 
public IntegrationFlow jmsInboundFlow1() { 
    return IntegrationFlows 
      .from(Jms.inboundAdapter(cachingConnectionFactory) 
        .configureJmsTemplate(t -> 
          t.deliveryPersistent(true).sessionTransacted(true).sessionAcknowledgeModeName("")) 
        .destination(inboundQueueName).headerMapper(defaultJmsHeaderMapper)) 
        .channel(MessageChannels.queue("inputChannel")) 
      .get(); 
} 

回答

2

你對DefaultMessageListenerContainer container = c.get();做了什麼是正確的方式來提供這些選項。

還有像使用Jms.container()廠變體:

Jms.messageDrivenChannelAdapter(
       Jms.container(this.jmsConnectionFactory, "containerSpecDestination") 
         .concurrentConsumers(20) 
         .maxConcurrentConsumers(30) 
         .get()) 

我們將在Spring集成5.0看看我們如何能夠提高configureListenerContainer()推斷泛型類型的目標容器類,讓流暢的API來處理直接使用JmsDefaultListenerContainerSpec

關於此事請參閱JIRA ticket