2017-05-04 126 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。 –