Last active
March 18, 2020 09:28
-
-
Save jforge/1dba9b16dbc653b24db795d2d8fe73b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Thread = Java.type("java.lang.Thread"); | |
| var System = Java.type("java.lang.System"); | |
| var String = Java.type("java.lang.String"); | |
| var topic = "service/ping"; | |
| function execute(action) { | |
| out("Test Script: " + action.getName()); | |
| for (var i = 0; i < 1000; i++) { | |
| randomTimeSeriesPing(); | |
| Thread.sleep(2000); | |
| } | |
| action.setExitCode(0); | |
| action.setResultText("done."); | |
| out("Test Script: Done"); | |
| return action; | |
| } | |
| function randomTimeSeriesPing() { | |
| var millis = System.currentTimeMillis(); | |
| out("time published: " + millis); | |
| var message = String.format("{ \"timestamp\": %d, \"value\": %f }", millis, Math.random()*100); | |
| mqttManager.publish(topic, message); | |
| } | |
| function out(message){ | |
| output.print(message); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment