ActiveMQ does not stop subscription when flex client disconnects

那年仲夏 提交于 2019-12-08 10:17:28

问题


I'm using activeMQ 5.3 to send messages to a flex client via blazeds 3.2.

When the client connects for the first time, I can see the subscriptions to the activeMQ broker being made. However, after I kill the browser that runs the client the subscriptions remain open even though no messages are being consumed anymore. This finally results in an out-of-memory of the web server. From the logs it looks like Blazeds is unsubscribing from the feeds.

Shouldn't blazeds stop the subscription when there are no clients that connect anymore and why isn't he doing that?

Below you can find a snippet from the log files.

...
STARTING WEB SERVER
...
14 Dec 2009 15:54:59,015 [main] DEBUG activemq.transport.vm.VMTransportFactory  - binding to broker: localhost
14 Dec 2009 15:54:59,031 [main] INFO  apache.activemq.broker.TransportConnector  - Connector vm://localhost Started
14 Dec 2009 15:54:59,031 [main] INFO  apache.activemq.broker.BrokerService  - ActiveMQ JMS Message Broker (localhost, ID:pcjbe-2026-1260802498843-0:0) started
...
CONNECTING WITH CLIENT
...
14 Dec 2009 15:55:03,953 [VMTransport] DEBUG apache.activemq.broker.TransportConnection  - Setting up new connection: vm://localhost#4
14 Dec 2009 15:55:03,968 [VMTransport] DEBUG activemq.broker.region.AbstractRegion  - localhost adding consumer: ID:pcjbe-2026-1260802498843-2:2:-1:1 for destination: topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic
14 Dec 2009 15:55:03,968 [http-8000-3] INFO  flex.messaging.jms.JmsAdapter  - client [AEE95CCE-816B-EBCC-2ACE-41508E3338AC] subscribed to destination [detectorsFeed]
14 Dec 2009 15:55:03,968 [VMTransport] DEBUG activemq.broker.region.AbstractRegion  - localhost adding consumer: ID:pcjbe-2026-1260802498843-2:2:1:1 for destination: topic://tmsng.topic.detectors
14 Dec 2009 15:55:03,968 [VMTransport] DEBUG activemq.broker.region.AbstractRegion  - localhost adding destination: topic://tmsng.topic.detectors
14 Dec 2009 15:55:03,968 [VMTransport] DEBUG activemq.broker.region.AbstractRegion  - localhost adding destination: topic://tmsng.topic.detectors
14 Dec 2009 15:55:03,968 [VMTransport] DEBUG activemq.broker.region.AbstractRegion  - localhost adding destination: topic://ActiveMQ.Advisory.Consumer.Topic.tmsng.topic.detectors
[BlazeDS]12/14/2009 15:55:03.968 [DEBUG] [Client.MessageClient] MessageClient created with clientId 'AEE95CCE-816B-EBCC-2ACE-41508E3338AC' for destination 'detectorsFeed'.
...
DISCONNECTING CLIENT
...
14 Dec 2009 15:58:55,156 [http-8000-8] INFO  flex.messaging.jms.JmsAdapter  - client [AEF0AC64-7B6C-2749-8860-252B8A302EBA] unsubscribed from destination [detectorsFeed]
[BlazeDS]12/14/2009 15:58:55.156 [DEBUG] [Client.MessageClient] MessageClient with clientId 'AEF0AC64-7B6C-2749-8860-252B8A302EBA' for destination 'detectorsFeed' has been invalidated.

Below you can find the configuration used to for ActiveMQ

<beans xmlns="http://www.springframework.org/schema/beans" ...>

<amq:broker brokerName="localhost" useJmx="true" persistent="false" dataDirectory="${INSTALLDIR}/var" >
    <amq:destinationPolicy>
        <amq:policyMap>
            <amq:policyEntries>
                <amq:policyEntry topic=">" producerFlowControl="false">
                    <amq:pendingSubscriberPolicy>
                        <amq:vmCursor/>
                    </amq:pendingSubscriberPolicy>
                </amq:policyEntry>
            </amq:policyEntries>
        </amq:policyMap>
    </amq:destinationPolicy>

    <amq:managementContext>
        <amq:managementContext createConnector="false"/>
    </amq:managementContext>

    <amq:systemUsage>
        <amq:systemUsage sendFailIfNoSpace="true">
            <amq:memoryUsage>
                <amq:memoryUsage limit="10mb" />
            </amq:memoryUsage>
        </amq:systemUsage>
    </amq:systemUsage>

    <amq:transportConnectors>
        <amq:transportConnector uri="vm://localhost" />
    </amq:transportConnectors>
</amq:broker>

<!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
<amq:connectionFactory id="connectionFactory" brokerURL="vm://localhost" alwaysSessionAsync="true">
    <amq:prefetchPolicy>
        <!-- For pooled connections, set the prefetch to 1 to avoid out-of-order messages. (see http://activemq.apache.org/what-is-the-prefetch-limit-for.html) -->
        <amq:prefetchPolicy all="1"/>   
    </amq:prefetchPolicy>
</amq:connectionFactory>

<!-- a pooling based JMS provider -->
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
    <property name="connectionFactory" ref="connectionFactory" />
</bean>

<amq:topic id="detectorTopic" physicalName="tmsng.topic.detectors" />

Best regards Jan


回答1:


Does look like a blazeds problem of not closing down the connection



来源:https://stackoverflow.com/questions/1901502/activemq-does-not-stop-subscription-when-flex-client-disconnects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!