Liberty中jmsQueueConnectionFactory的createConnection()超时设置问题
The issue here is that the connectionTimeout on your connectionManager doesn’t control the MQ connection establishment timeout—that property only governs how long the application waits to grab a connection from the pool when all pooled connections are in use. The 2-minute delay you’re seeing is the default OS-level TCP timeout kicking in when the firewall blocks the connection attempt.
To fix this, you need to configure timeout settings specific to the IBM MQ JMS client directly in the properties.wmqJms element of your connection factory. Here’s what to do:
Add MQ-Specific Timeout Properties
Modify your properties.wmqJms section to include the connectTimeout attribute, which sets the maximum time (in milliseconds) the client waits for a connection to the queue manager to be established. You can also add socketTimeout if you want to control timeouts for subsequent socket operations, but connectTimeout is the critical one for your scenario.
Here’s the updated server.xml snippet:
<jmsQueueConnectionFactory id="myConnectionFactory" jndiName="myJNDI" connectionManagerRef="ConMgr0"> <properties.wmqJms transportType="CLIENT" hostName="x.x.x.x" port="1234" channel="myChannel" queueManager="myQmanager" userName="myUSER" password="myPW" connectTimeout="10000" <!-- 10 seconds in milliseconds --> socketTimeout="30000" <!-- Optional: 30 seconds for ongoing socket operations --> /> </jmsQueueConnectionFactory> <connectionManager id="ConMgr0" maxPoolSize="10" agedTimeout="0s" connectionTimeout="10s"/>
Key Notes:
connectTimeout: This directly overrides the OS TCP timeout for initial MQ connection attempts. Setting it to10000(10 seconds) will fail the connection much faster when the firewall blocks access.- Version Compatibility: Liberty 18.0.0.1 supports the
connectTimeoutproperty forwmqJms, but if you run into issues, double-check that you have the latest fix pack applied for your Liberty installation. - Restart Required: Don’t forget to restart your Liberty server after updating the server.xml to apply the new settings.
This should resolve the 2-minute delay you’re experiencing when the firewall blocks the MQ connection.
内容的提问来源于stack exchange,提问作者kinglite

