最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to silence Spring Integration TCP Pool Timeout - Stack Overflow

programmeradmin3浏览0评论

Whenever my tcp client is down, I get these big errors:

How do I silence it? I don't see it going to errorChannel for some reason.

 ERROR [main][.springframework.integration.ip.tcp.TcpSendingMessageHandler] Error creating connection
.springframework.integration.util.PoolItemNotAvailableException: Timed out while waiting to acquire a pool entry.
    at .springframework.integration.util.SimplePool.getItem(SimplePool.java:202) ~[spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.connection.CachingClientConnectionFactory.obtainConnection(CachingClientConnectionFactory.java:123) ~[spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:120) ~[spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:42) ~[spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.obtainConnection(TcpSendingMessageHandler.java:90) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.doWrite(TcpSendingMessageHandler.java:180) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.handleMessageAsClient(TcpSendingMessageHandler.java:150) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.handleMessageInternal(TcpSendingMessageHandler.java:110) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:105) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:132) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:390) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:334) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:304) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.samples.tcpclientserver.Main.main(Main.java:23) [classes/:?]

I am using tcp outbound adapter:

<bean id="javaSerializer"
      class=".springframework.core.serializer.DefaultSerializer"/>
<bean id="javaDeserializer"
      class=".springframework.core.serializer.DefaultDeserializer"/>

<int-ip:tcp-connection-factory id="client"
    type="client"
    host="localhost"
    port="#{server.port}"
    single-use="true"
    so-timeout="10000"
    deserializer="javaDeserializer"
    serializer="javaSerializer"/>

<int:channel id="input" />

<int:channel id="replies">
    <int:queue/>
</int:channel>

<int-ip:tcp-outbound-channel-adapter id="outboundClient"
    channel="input"
    connection-factory="client"/>

<int-ip:tcp-inbound-channel-adapter id="inboundClient"
    channel="replies"
    connection-factory="client"/>

Let me if there are way to supress these, I don't want my log to fill up unnecessarily as I know Pool Item Not available means server is down, or latency is too high.

Whenever my tcp client is down, I get these big errors:

How do I silence it? I don't see it going to errorChannel for some reason.

 ERROR [main][.springframework.integration.ip.tcp.TcpSendingMessageHandler] Error creating connection
.springframework.integration.util.PoolItemNotAvailableException: Timed out while waiting to acquire a pool entry.
    at .springframework.integration.util.SimplePool.getItem(SimplePool.java:202) ~[spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.connection.CachingClientConnectionFactory.obtainConnection(CachingClientConnectionFactory.java:123) ~[spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:120) ~[spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:42) ~[spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.obtainConnection(TcpSendingMessageHandler.java:90) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.doWrite(TcpSendingMessageHandler.java:180) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.handleMessageAsClient(TcpSendingMessageHandler.java:150) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.ip.tcp.TcpSendingMessageHandler.handleMessageInternal(TcpSendingMessageHandler.java:110) [spring-integration-ip-6.4.0-20240830.202717-140.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:105) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:132) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:390) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:334) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:304) [spring-integration-core-6.4.0-20240830.202717-135.jar:6.4.0-SNAPSHOT]
    at .springframework.integration.samples.tcpclientserver.Main.main(Main.java:23) [classes/:?]

I am using tcp outbound adapter:

<bean id="javaSerializer"
      class=".springframework.core.serializer.DefaultSerializer"/>
<bean id="javaDeserializer"
      class=".springframework.core.serializer.DefaultDeserializer"/>

<int-ip:tcp-connection-factory id="client"
    type="client"
    host="localhost"
    port="#{server.port}"
    single-use="true"
    so-timeout="10000"
    deserializer="javaDeserializer"
    serializer="javaSerializer"/>

<int:channel id="input" />

<int:channel id="replies">
    <int:queue/>
</int:channel>

<int-ip:tcp-outbound-channel-adapter id="outboundClient"
    channel="input"
    connection-factory="client"/>

<int-ip:tcp-inbound-channel-adapter id="inboundClient"
    channel="replies"
    connection-factory="client"/>

Let me if there are way to supress these, I don't want my log to fill up unnecessarily as I know Pool Item Not available means server is down, or latency is too high.

Share Improve this question asked Apr 1 at 5:40 tofutofu 111 bronze badge New contributor tofu is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

The code you talk about is this:

protected TcpConnection obtainConnection(Message<?> message) {
    TcpConnection connection;
    Assert.notNull(this.clientConnectionFactory, "'clientConnectionFactory' cannot be null");
    try {
        connection = this.clientConnectionFactory.getConnection();
    }
    catch (Exception ex) {
        logger.error(ex, "Error creating connection");
        throw new MessageHandlingException(message, "Failed to obtain a connection in the [" + this + ']', ex);
    }
    return connection;
}

I think we can turn it to warn or just remove that logging altogether because we are throwing that MessageHandlingException any way.

For time being you can "silence" using logging configuration.

Set category .springframework.integration.ip.tcp.TcpSendingMessageHandler to the FATAL.

发布评论

评论列表(0)

  1. 暂无评论