You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Chester_Zheng <ch...@sina.com> on 2017/05/03 02:11:26 UTC

Re: Re: The connection is already closed

Hi, Tim

First of all, Thanks for your response.

I know the exception message is on the factory, and the close() method is a public-method that anywhere can invoke it if it has the factory instance.
I've seen the source code and found the exception message. 
But, I can't understand why ActiveMQ appear this exception without any explicitly invoke.
I've used debugger and set a breakpoint on the connection's close() method.
Unfortunately, I still don't meet the exception after that day. I don't know how it can reproduce.

I extremely wanna know when ActiveMQ will invoke the close() method implicitly or explicitly.

Thanks.

Chester


chester_zheng@sina.com
 
From: Tim Bain [via ActiveMQ]
Date: 2017-05-01 04:20
To: Chester_Zheng
Subject: Re: The connection is already closed
The close() methods you referenced are on the factory, while the error 
message you're getting is about the close() method of the connections 
returned by the factory. 

If you can reproduce the problem in a non-operational environment, attach a 
debugger and set a breakpoint on the connection's close() method to see 
where it's being called. If not, you could use Eclipse's Find References 
feature to look for it. Keep in mind that a try-with-resources calls 
close(), so you may not find the call to close() written out explicitly. 

Tim 

On Apr 27, 2017 8:00 AM, "Chester_Zheng" <[hidden email]> wrote: 

> Hi, Dear All 
> I match a strange problem. We built a master/slave cluster of ActiveMQ by 
> using zookeeper as a registration center. 
> First of all, we use the "CachingConnectionFactory" which get from "Spring" 
> to create the ActiveMQ connection. 
> Then, we establish a custom session pool that it's easy to get a session 
> for 
> the high-concurrency scenarios. 
> 
> Strangely, both of test and pulbic enviornment java code is the same, but I 
> didn't find this problem on own test enviornment. 
> 
> P.S.I did the pressure test on the test-enviornment. 
> 
> Is it my wrong way to use or a real bug of ActiveMQ? When And where the 
> ActiveMQ will invoke the method named "close" by itself? 
> 
> I've already seen the ActiveMQ-source. The "CachingConnectionFactory" is 
> extended "SingleConnectionFactory".And I seen the method named "close". 
> There is a private final field named "closed". And the default value is 
> "false". When somewhere invokes the close method, then the filed "closed" 
> will change to "true". 
> 
> If you guys met similar like what I described, Please let me know. Thanks a 
> lot. 
> 
> Here is the error message: 
> 
> org.apache.activemq.ConnectionClosedException: The connection is already 
> closed 
>         at 
> org.apache.activemq.ActiveMQConnection.checkClosed( 
> ActiveMQConnection.java:1477) 
>         at 
> org.apache.activemq.ActiveMQConnection.checkClosedOrFailed( 
> ActiveMQConnection.java:1464) 
>         at 
> org.apache.activemq.ActiveMQConnection.createSession( 
> ActiveMQConnection.java:323) 
>         at 
> org.springframework.jms.connection.SingleConnectionFactory.createSession( 
> SingleConnectionFactory.java:416) 
>         at 
> org.springframework.jms.connection.CachingConnectionFactory.getSession( 
> CachingConnectionFactory.java:234) 
>         at 
> org.springframework.jms.connection.SingleConnectionFactory$ 
> SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:556) 
>         at com.sun.proxy.$Proxy16.createSession(Unknown Source) 
>         at 
> com.bs.pid.link.dc.activemq.util.SessionFactory$1.run( 
> SessionFactory.java:120) 
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker( 
> ThreadPoolExecutor.java:1145) 
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run( 
> ThreadPoolExecutor.java:615) 
>         at java.lang.Thread.run(Thread.java:745) 
> 
> The configuration is : 
> 
> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="bs" 
> schedulePeriodForDestinationPurge="10000"  useShutdownHook="false" 
> dataDirectory="${activemq.data}" 
> splitSystemUsageForProducersConsumers="true" producerSystemUsagePortion=" 
> 50" 
> consumerSystemUsagePortion="50"> 
> 
>         <destinationPolicy> 
>             <policyMap> 
>               <policyEntries> 
>                 <policyEntry topic=">" > 
>                   <pendingMessageLimitStrategy> 
>                     <constantPendingMessageLimitStrategy limit="1000"/> 
>                   </pendingMessageLimitStrategy> 
>                 </policyEntry> 
>               <policyEntry queue=">" gcInactiveDestinations="true" 
> inactiveTimoutBeforeGC="30000"  producerFlowControl="true" 
> memoryLimit="512mb"> 
> 
>              <dispatchPolicy> 
>                <strictOrderDispatchPolicy/> 
>              </dispatchPolicy> 
>              <subscriptionRecoveryPolicy> 
>                <lastImageSubscriptionRecoveryPolicy/> 
>              </subscriptionRecoveryPolicy> 
>              <pendingQueuePolicy> 
>                <storeCursor/> 
>              </pendingQueuePolicy> 
>                 </policyEntry> 
>                </policyEntries> 
>             </policyMap> 
>         </destinationPolicy> 
> 
>         <managementContext> 
>             <managementContext createConnector="false"/> 
>         </managementContext> 
> 
>         <persistenceAdapter> 
>             <replicatedLevelDB 
>                 directory="activemq-data" 
>                 replicas="3" 
>                 bind="tcp://0.0.0.0:61619" 
> 
> zkAddress="xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181" 
>                 zkPath="/opt/apache-activemq-5.13.4/data/leveldb-stores" 
>                 zkSessionTimeout="3s" 
>                 hostname="xxx.xxx.xxx.xxx" 
>                 weight="1" 
>       /> 
> 
>     </persistenceAdapter> 
>           <systemUsage> 
>             <systemUsage> 
>                 <memoryUsage> 
>                       <memoryUsage limit="1024 mb"/> 
>                 </memoryUsage> 
>                 <storeUsage> 
>                     <storeUsage limit="20 gb"/> 
>                 </storeUsage> 
>                 <tempUsage> 
>                     <tempUsage limit="10 gb"/> 
>                 </tempUsage> 
>             </systemUsage> 
>         </systemUsage> 
> 
>         <transportConnectors> 
> 
>             <transportConnector name="openwire" 
> uri="tcp://0.0.0.0:61616?maximumConnections=3000&amp; 
> wireFormat.maxFrameSize=104857600"/> 
>         </transportConnectors> 
> 
> 
>         <shutdownHooks> 
>             <bean xmlns="http://www.springframework.org/schema/beans" 
> class="org.apache.activemq.hooks.SpringContextHook" /> 
>         </shutdownHooks> 
>     </broker> 
> 
> 
> The client URL is : 
> 
> failover\://(tcp\:/xxx.xxx.xxx.xxx:61616?tcpNoDelay\= 
> true,tcp\://xxx.xxx.xxx.xxx:61616?tcpNoDelay\=true,tcp\:// 
> xxx.xxx.xxx.xxx:61616?tcpNoDelay\=true)?nested.wireFormat. 
> maxInactivityDuration\=3000&nested.wireFormat.tightEncodingEnabled=false& 
> nested.connectionTimeout\=0&timeout\=200&initialReconnectDelay\=10& 
> startupMaxReconnectAttempts\=2&maxReconnectDelay\=100&jms. 
> prefetchPolicy.all\=2&randomize\=false&backup\=true 
> 
> 
> 
> 
> 
> 
> -- 
> View this message in context: http://activemq.2283324.n4. 
> nabble.com/The-connection-is-already-closed-tp4725268.html 
> Sent from the ActiveMQ - User mailing list archive at Nabble.com. 
> 




If you reply to this email, your message will be added to the discussion below:
http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-4-The-connection-is-already-closed-tp4725268p4725379.html 
To unsubscribe from ActiveMQ-5.13.4 "The connection is already closed", click here.
NAML 




--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-4-The-connection-is-already-closed-tp4725268p4725493.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Re: The connection is already closed

Posted by Chester_Zheng <ch...@sina.com>.
Hi, Tim

Happy to communicate with u again.

I pasted the exception message on my first message.
It didn't show any detailed or explicit hint.
There's not any valuable info about how to deal with the problem.
No any message is about Brokers.

I only set the value "nested.wireFormat.maxInactivityDuration=3000" on
client, but I don't think it's the reason of that exception because the
Brokers still produce and consume messsages.
If any inactive queue is deleted before I use it, that would be confirm the
queue is not inactive.
I check the exception on the internet, but no-one meet the same problem.

I understand the exception is about *connection*, not the factory.

If the close() method is invoked by the third-party libraries that I invoke,
I think it's definitely hard to find.

Chester




--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-4-The-connection-is-already-closed-tp4725268p4725495.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Re: The connection is already closed

Posted by Tim Bain <tb...@alumni.duke.edu>.
On May 2, 2017 8:23 PM, "Chester_Zheng" <ch...@sina.com> wrote:

Hi, Tim

First of all, Thanks for your response.

I know the exception message is on the factory


No, the exception message is about the *connection*, not the factory.

, and the close() method is a public-method that anywhere can invoke it if
it has the factory instance.
I've seen the source code and found the exception message.
But, I can't understand why ActiveMQ appear this exception without any
explicitly invoke.


Two situations I can think of that would result in a connection being
closed without any action on your part are a TCP connection problem (due to
such problems as network hiccups or firewall misconfiguration) or an
inactivity interval elapsing (which should result in log lines in one or
both of the client or the broker). Connections can also be closed if your
code (or a third-party library you invoke) calls close().

I've used debugger and set a breakpoint on the connection's close() method.
Unfortunately, I still don't meet the exception after that day. I don't
know how it can reproduce.


Is there anything relevant in the broker's logs?

I extremely wanna know when ActiveMQ will invoke the close() method
implicitly or explicitly.

Thanks.

Chester


chester_zheng@sina.com

From: Tim Bain [via ActiveMQ]
Date: 2017-05-01 04:20
To: Chester_Zheng
Subject: Re: The connection is already closed
The close() methods you referenced are on the factory, while the error
message you're getting is about the close() method of the connections
returned by the factory.

If you can reproduce the problem in a non-operational environment, attach a
debugger and set a breakpoint on the connection's close() method to see
where it's being called. If not, you could use Eclipse's Find References
feature to look for it. Keep in mind that a try-with-resources calls
close(), so you may not find the call to close() written out explicitly.

Tim

On Apr 27, 2017 8:00 AM, "Chester_Zheng" <[hidden email]> wrote:

> Hi, Dear All
> I match a strange problem. We built a master/slave cluster of ActiveMQ by
> using zookeeper as a registration center.
> First of all, we use the "CachingConnectionFactory" which get from
"Spring"
> to create the ActiveMQ connection.
> Then, we establish a custom session pool that it's easy to get a session
> for
> the high-concurrency scenarios.
>
> Strangely, both of test and pulbic enviornment java code is the same, but
I
> didn't find this problem on own test enviornment.
>
> P.S.I did the pressure test on the test-enviornment.
>
> Is it my wrong way to use or a real bug of ActiveMQ? When And where the
> ActiveMQ will invoke the method named "close" by itself?
>
> I've already seen the ActiveMQ-source. The "CachingConnectionFactory" is
> extended "SingleConnectionFactory".And I seen the method named "close".
> There is a private final field named "closed". And the default value is
> "false". When somewhere invokes the close method, then the filed "closed"
> will change to "true".
>
> If you guys met similar like what I described, Please let me know. Thanks
a
> lot.
>
> Here is the error message:
>
> org.apache.activemq.ConnectionClosedException: The connection is already
> closed
>         at
> org.apache.activemq.ActiveMQConnection.checkClosed(
> ActiveMQConnection.java:1477)
>         at
> org.apache.activemq.ActiveMQConnection.checkClosedOrFailed(
> ActiveMQConnection.java:1464)
>         at
> org.apache.activemq.ActiveMQConnection.createSession(
> ActiveMQConnection.java:323)
>         at
> org.springframework.jms.connection.SingleConnectionFactory.createSession(
> SingleConnectionFactory.java:416)
>         at
> org.springframework.jms.connection.CachingConnectionFactory.getSession(
> CachingConnectionFactory.java:234)
>         at
> org.springframework.jms.connection.SingleConnectionFactory$
> SharedConnectionInvocationHandler.invoke(SingleConnectionFactory.java:556)
>         at com.sun.proxy.$Proxy16.createSession(Unknown Source)
>         at
> com.bs.pid.link.dc.activemq.util.SessionFactory$1.run(
> SessionFactory.java:120)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1145)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:615)
>         at java.lang.Thread.run(Thread.java:745)
>
> The configuration is :
>
> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="bs"
> schedulePeriodForDestinationPurge="10000"  useShutdownHook="false"
> dataDirectory="${activemq.data}"
> splitSystemUsageForProducersConsumers="true" producerSystemUsagePortion="
> 50"
> consumerSystemUsagePortion="50">
>
>         <destinationPolicy>
>             <policyMap>
>               <policyEntries>
>                 <policyEntry topic=">" >
>                   <pendingMessageLimitStrategy>
>                     <constantPendingMessageLimitStrategy limit="1000"/>
>                   </pendingMessageLimitStrategy>
>                 </policyEntry>
>               <policyEntry queue=">" gcInactiveDestinations="true"
> inactiveTimoutBeforeGC="30000"  producerFlowControl="true"
> memoryLimit="512mb">
>
>              <dispatchPolicy>
>                <strictOrderDispatchPolicy/>
>              </dispatchPolicy>
>              <subscriptionRecoveryPolicy>
>                <lastImageSubscriptionRecoveryPolicy/>
>              </subscriptionRecoveryPolicy>
>              <pendingQueuePolicy>
>                <storeCursor/>
>              </pendingQueuePolicy>
>                 </policyEntry>
>                </policyEntries>
>             </policyMap>
>         </destinationPolicy>
>
>         <managementContext>
>             <managementContext createConnector="false"/>
>         </managementContext>
>
>         <persistenceAdapter>
>             <replicatedLevelDB
>                 directory="activemq-data"
>                 replicas="3"
>                 bind="tcp://0.0.0.0:61619"
>
> zkAddress="xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181"
>                 zkPath="/opt/apache-activemq-5.13.4/data/leveldb-stores"
>                 zkSessionTimeout="3s"
>                 hostname="xxx.xxx.xxx.xxx"
>                 weight="1"
>       />
>
>     </persistenceAdapter>
>           <systemUsage>
>             <systemUsage>
>                 <memoryUsage>
>                       <memoryUsage limit="1024 mb"/>
>                 </memoryUsage>
>                 <storeUsage>
>                     <storeUsage limit="20 gb"/>
>                 </storeUsage>
>                 <tempUsage>
>                     <tempUsage limit="10 gb"/>
>                 </tempUsage>
>             </systemUsage>
>         </systemUsage>
>
>         <transportConnectors>
>
>             <transportConnector name="openwire"
> uri="tcp://0.0.0.0:61616?maximumConnections=3000&amp;
> wireFormat.maxFrameSize=104857600"/>
>         </transportConnectors>
>
>
>         <shutdownHooks>
>             <bean xmlns="http://www.springframework.org/schema/beans"
> class="org.apache.activemq.hooks.SpringContextHook" />
>         </shutdownHooks>
>     </broker>
>
>
> The client URL is :
>
> failover\://(tcp\:/xxx.xxx.xxx.xxx:61616?tcpNoDelay\=
> true,tcp\://xxx.xxx.xxx.xxx:61616?tcpNoDelay\=true,tcp\://
> xxx.xxx.xxx.xxx:61616?tcpNoDelay\=true)?nested.wireFormat.
> maxInactivityDuration\=3000&nested.wireFormat.tightEncodingEnabled=false&
> nested.connectionTimeout\=0&timeout\=200&initialReconnectDelay\=10&
> startupMaxReconnectAttempts\=2&maxReconnectDelay\=100&jms.
> prefetchPolicy.all\=2&randomize\=false&backup\=true
>
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/The-connection-is-already-closed-tp4725268.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>




If you reply to this email, your message will be added to the discussion
below:
http://activemq.2283324.n4.nabble.com/ActiveMQ-5-13-4-
The-connection-is-already-closed-tp4725268p4725379.html
To unsubscribe from ActiveMQ-5.13.4 "The connection is already closed",
click here.
NAML




--
View this message in context: http://activemq.2283324.n4.
nabble.com/ActiveMQ-5-13-4-The-connection-is-already-
closed-tp4725268p4725493.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.