Documentation of the Test-Client-Server tool used for example.test
.
The Naming-Test-Tool tool is used to test the name-resolution-feature of jvmqmsgque.
To perform the test 2 tools are used, the testclient and the testserver.
testclient | This tool creates multiple parent and child client-context, all using a |
testserver | This tool listen on the service GTCX and return the unique identification pattern of the server-context in duty. |
All context created, 8x client and 8x server, are connected using the jvmqmsgque protocoll and build together a flat structure.
The GOAL for this setup is:
/** * @file NHI1/example/jv/testclient.java * @brief testclient.java - 19 Aug 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permissions to copy, * please contact AUTHOR for additional information * @version a5cb9f916df9a2d44f91871d69b296ab9a9d1e68 * @date Mon Aug 19 14:57:57 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ package example; import java.util.List; import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import jvmsgque.mqmsgque.*; import jvmsgque.mkkernel.*; class testclient extends MqContextC { // my helper private StringBuffer Get() { StringBuffer RET = new StringBuffer(); SendSTART(); SendEND_AND_WAIT("GTCX", -2); RET.append(ConfigGetName()); RET.append("+"); RET.append(ReadSTR()); RET.append(ReadSTR()); RET.append(ReadSTR()); RET.append(ReadSTR()); RET.append(ReadSTR()); RET.append(ReadSTR()); return RET; } public static void main(String[] argv) { // setup the clients List<String> LIST1 = new ArrayList<>(Arrays.asList("--prefix", "c", "--postfix", "1")); LIST1.addAll(Arrays.asList(argv)); List<String> LIST0 = Arrays.asList("--prefix", "c", "--postfix", "0", "--debug", System.getenv("TS_DEBUG"), "@", "java", "example.testserver", "--prefix", "s"); // create the objects testclient c0 = new testclient(); testclient c00 = new testclient(); testclient c01 = new testclient(); testclient c000 = new testclient(); testclient c1 = new testclient(); testclient c10 = new testclient(); testclient c100 = new testclient(); testclient c101 = new testclient(); try { // create the Link c0.LinkCreate(LIST0.toArray(new String[0])); c00.LinkCreateChild (c0, "--postfix", "00" ); c01.LinkCreateChild (c0, "--postfix", "01" ); c000.LinkCreateChild (c00, "--postfix", "000" ); c1.LinkCreate(LIST1.toArray(new String[0])); c10.LinkCreateChild (c1, "--postfix", "10" ); c100.LinkCreateChild (c10, "--postfix", "100" ); c101.LinkCreateChild (c10, "--postfix", "101" ); // do the tests System.out.println(c0.Get()); System.out.println(c00.Get()); System.out.println(c01.Get()); System.out.println(c000.Get()); System.out.println(c1.Get()); System.out.println(c10.Get()); System.out.println(c100.Get()); System.out.println(c101.Get()); } catch (Throwable e) { c0.ErrorCatch(e); } finally { // do the cleanup c1.LinkDelete(); c0.Exit(); } } }
/** * @file NHI1/example/jv/testserver.java * @brief testserver.java - 19 Aug 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permissions to copy, * please contact AUTHOR for additional information * @version a5cb9f916df9a2d44f91871d69b296ab9a9d1e68 * @date Mon Aug 19 14:57:57 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ package example; import jvmsgque.mqmsgque.*; import jvmsgque.mkkernel.*; final class testserver extends MqContextC implements IServerSetup { public testserver(MqContextC tmpl) { super(tmpl); } class GTCX implements MqServiceIF { public void Callback(MqContextC ctx) { SendSTART(); SendI32(LinkGetCtxId()); SendSTR("+"); if (LinkIsParent()) { SendI32(-1); } else { SendI32(LinkGetParent().LinkGetCtxId()); } SendSTR("+"); SendSTR(ConfigGetName()); SendSTR(":"); SendRETURN(); } } public void ServerSetup() { ServiceCreate("GTCX", new GTCX()); } public static void main(String[] argv) { MqContextC srv = MqFactoryC.Add(testserver.class).New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Throwable e) { srv.ErrorCatch(e); } finally { srv.Exit(); } } }