Spring集成TCP性能监视器

问题描述 投票:0回答:1

我现在正在编码基于https://github.com/spring-projects/spring-integration-samples/tree/master/basic/tcp-client-server

我想知道这个好的源代码示例的监控信息。

例如,我想知道有多少客户端已连接?正在使用多少个线程?

是否有人可以重播我的问题。

spring performance spring-integration
1个回答
0
投票

你可以在AbstractConnectionFactory上使用它:

/**
 * Returns a list of (currently) open {@link TcpConnection} connection ids; allows,
 * for example, broadcast operations to all open connections.
 * @return the list of connection ids.
 */
public List<String> getOpenConnectionIds() {
    return Collections.unmodifiableList(this.removeClosedConnectionsAndReturnOpenConnectionIds());
}

您可以从外部配置的ThreadPoolTaskExecutor获取并通过以下方式注入到AbstractConnectionFactory的线程统计信息:

/**
 * @param taskExecutor the taskExecutor to set
 */
public void setTaskExecutor(Executor taskExecutor) {
    this.taskExecutor = taskExecutor;
}
© www.soinside.com 2019 - 2024. All rights reserved.