2017-05-04 84 views
1

我們有一個應用程序,每分鐘可以消耗約300個JMS消息。我們需要將速度提高到每分鐘3000條。提高應用程序的JMS消息消耗速度

我創建了一個簡單的測試程序,它從隊列中讀取消息並記錄消息。不涉及處理,所以我期望高速。但是,日誌記錄仍在以每分鐘約400條消息的速度發生。

下面是我的程序

<int-jms:message-driven-channel-adapter id="testJmsInboundAdapter" 
    auto-startup="true" 
    destination="testQueueDestination" 
    connection-factory="testConnectionFactory" 
    channel="messageTransformerChannel" /> 

<int:channel id="messageTransformerChannel" /> 

<int:service-activator 
    id="loggerActivator" 
    input-channel="messageTransformerChannel" 
    method="log" 
    ref="logger" /> 

的記錄方法的摘錄只需登錄該消息

public void log(final GenericMessage<Object> object) { 
     LOGGER.info("Logging message" + object); 
    } 

任何建議,我應該看的瓶頸。是否有可以每分鐘使用Spring集成的消息驅動通道適配器

回答

0

關注這些選項被消費的消息數量的任何限制:使用併發消費

<xsd:attribute name="concurrent-consumers" type="xsd:string"> 
     <xsd:annotation> 
      <xsd:documentation> 
       Specify the number of concurrent consumers to create. Default is 1. 
        Specifying a higher value for this setting will increase the standard 
        level of scheduled concurrent consumers at runtime: This is effectively 
        the minimum number of concurrent consumers which will be scheduled 
        at any given time. This is a static setting; for dynamic scaling, 
        consider specifying the "maxConcurrentConsumers" setting instead. 
        Raising the number of concurrent consumers is recommendable in order 
        to scale the consumption of messages coming in from a queue. However, 
        note that any ordering guarantees are lost once multiple consumers are 
        registered 
      </xsd:documentation> 
     </xsd:annotation> 
    </xsd:attribute> 
    <xsd:attribute name="max-concurrent-consumers" type="xsd:string"> 
     <xsd:annotation> 
      <xsd:documentation> 
       Specify the maximum number of concurrent consumers to create. Default is 1. 
        If this setting is higher than "concurrentConsumers", the listener container 
        will dynamically schedule new consumers at runtime, provided that enough 
        incoming messages are encountered. Once the load goes down again, the number of 
        consumers will be reduced to the standard level ("concurrentConsumers") again. 
        Raising the number of concurrent consumers is recommendable in order 
        to scale the consumption of messages coming in from a queue. However, 
        note that any ordering guarantees are lost once multiple consumers are 
        registered. 
      </xsd:documentation> 
     </xsd:annotation> 
    </xsd:attribute> 
+0

謝謝=「5 「將處理速度提高到每分鐘2k條消息 – vjm

+0

您能否解釋併發消費者財產如何運作?如果將併發消費者值設置爲5,它是否會創建5個線程,這些線程同時從JMS隊列開始讀取。另外,如果最終消費上述示例中檢索到的消息的記錄器Bean是範圍原型的 - 將爲每個線程創建不同的記錄器bean,或者將所有線程引用同一個記錄器bean – vjm

+0

是的,他們將同時執行此操作。記錄器bean將僅爲Service Activator端點創建一次,並且僅在應用程序啓動應用程序期間創建。一切都休息了,請閱讀'DefaultMessageListenerContainer.setConcurrency(String concurrency)'JavaDocs。 –