如果消息过程之一花费了较长时间,HornetQ使用者将不会收到消息

时间:2019-02-07 05:23:03

标签: spring jms hornetq wildfly-9 spring-jmx

我正在处理有关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条消息。

是否满足以下条件

  1. 客户收到第一条消息,大约需要5分钟才能完成
  2. 剩下的19个用户发送和接收接下来的19条消息,然后所有这些消息都被每个消费者使用,这些都将在几秒钟之内完成,说(10秒)
  3. 现在,如果我发送1条消息,但是由于所有使用者都忙并且进入队列,该消息将不会传递给客户端,但是在完成上述第19条消息后,所有使用者都是空闲的,但最后一条消息仍在队列中(不交付给消费者)。仅在第一条消息(共5分钟)完成后,才会发送此消息。
  4. 在完成第19条消息后,如果我发送新消息,则该消息将立即发送给消费者,但以上单个消息仍在排队。

有人可以告诉我如何解决此问题,如果有任何免费的消费者,则应立即提取下一条消息。

我已经准备了一个项目,您可以通过该项目重现此方案。 ProjectDemo

预先感谢

0 个答案:

没有答案