Spring集成TCP性能监视器

时间:2017-12-19 13:30:02

标签: spring performance spring-integration

我现在根据https://github.com/spring-projects/spring-integration-samples/tree/master/basic/tcp-client-server

进行编码

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

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

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

1 个答案:

答案 0 :(得分: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;
}