gpt4 book ai didi

java - 如何优雅地结束测试客户端

转载 作者:太空宇宙 更新时间:2023-11-04 10:25:06 27 4
gpt4 key购买 nike

我有一个简单的累积速度测试客户端。代码运行良好,但代码完成后 jvm 不会停止。一些线程仍在运行:MultiThreadedHttpConnectionManager。

如何正常关闭分配的打开连接:

InventoryApi inventory = platform.getInventoryApi() ?

_

...
platform = new PlatformImpl(App.C8Y_URL, new CumulocityCredentials(App.C8Y_USER, App.C8Y_PWD));
InventoryApi inventory = platform.getInventoryApi();

GId testId = new GId("123456");
ManagedObjectRepresentation testDevice = inventory.get(testId);
MeasurementApi mApi = platform.getMeasurementApi();

MeasurementRepresentation measurement = new MeasurementRepresentation();
measurement.setType("c8y_SampleRate");
measurement.setSource(testDevice);

DateTime time = new DateTime();
System.out.println("time " + time.toString());
measurement.setDateTime(time);
Map<String, Object> flowRateFragment = App.createFlowRateFragment(new BigDecimal(20.5));
measurement.set(flowRateFragment, "c8y_SampleRate");

MeasurementRepresentation measurementCreation = mApi.create(measurement);
...

最佳答案

要正常关闭您的 Cumulocity 客户端,请调用 platform.close()

关于java - 如何优雅地结束测试客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50640105/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com