我正在处理有关HornetQ Queue问题的实时生产问题。
以下是我的应用程序的堆栈
Wildfly 9.0.2
HornetQ 2.4.7
Spring 4.3
我在Wildfly中为hornetq使用netty连接,以下是
中的配置standalone-full.xml
<connection-factory name="RemoteConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="RemoteConnectionFactory"/>
<entry name="java:jboss/exported/RemoteConnectionFactory"/>
</entries>
<block-on-non-durable-send>false</block-on-non-durable-send>
<block-on-durable-send>false</block-on-durable-send>
<consumer-window-size>0</consumer-window-size>
</connection-factory>
Spring配置如下。
<bean id = "atfQueueMDP" class = "org.springframework.jms.listener.DefaultMessageListenerContainer" >
<property name = "concurrentConsumers" value = "20"/>
<property name = "connectionFactory" ref = "connectionFactory"/>
<property name = "destination" ref = "atfQueue"/>
<property name = "messageListener" ref = "messageListener"/>
<property name = "sessionAcknowledgeMode" value = "2"/>
</bean>
<bean id="connectionFactory" class="org.hornetq.jms.client.HornetQJMSConnectionFactory">
<constructor-arg value="false"/>
<constructor-arg>
<bean name="transportConfiguration" class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory" />
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="host" value="localhost" />
<entry key="port" value="5445" />
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean id = "ATFJmsTemplate" class = "org.springframework.jms.core.JmsTemplate">
<property name = "connectionFactory">
<ref bean = "connectionFactory"/>
</property>
<property name = "sessionAcknowledgeMode" value = "2"/>
<property name = "receiveTimeout">
<value>-1</value>
</property>
</bean>
<bean id = "atfQueue" class = "org.springframework.jndi.JndiObjectFactoryBean" >
<property name = "jndiTemplate">
<ref bean = "jndiTemplate"/>
</property>
<property name = "jndiName">
<value>queue/ATFQueue</value>
</property>
</bean>
<bean id = "messageListener" class = "com.example.jms.receiver.ATFReceiver" />
现在问题如下。
我将并发使用者指定为20,因此,根据我的理解,侦听器可以处理并发20条消息。
是否满足以下条件
有人可以告诉我如何解决此问题,如果有任何免费的消费者,则应立即提取下一条消息。
我已经准备了一个项目,您可以通过该项目重现此方案。 ProjectDemo
预先感谢