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 csmqmsgque.
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 csmqmsgque protocoll and build together a flat structure.
The GOAL for this setup is:
/** * @file NHI1/example/cs/testclient.cs * @brief testclient.cs - 26 Jun 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permission to copy, * please contact AUTHOR for additional information * @version 08a242faddae5101924d8fe811888e78892a82d9 * @date Wed Jun 26 14:26:21 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ using System; using System.IO; using System.Text; using System.Collections.Generic; using System.Reflection; using csmqmsgque; namespace example { sealed class testclient : MqContextC { private StringBuilder Get() { StringBuilder RET = new StringBuilder(); SendSTART(); SendEND_AND_WAIT("GTCX"); 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; } static void Main(string[] argv) { // setup the clients string dirname = new FileInfo(Assembly.GetEntryAssembly().Location).DirectoryName; string server = Path.Combine(dirname, "testserver.exe"); List<String> LIST1 = new List<String>() {"--prefix", "c", "--postfix", "1"}; LIST1.AddRange(argv); List<String> LIST0 = new List<String>() { "--prefix", "c", "--postfix", "0", "--debug", System.Environment.GetEnvironmentVariable("TS_DEBUG"), "@" }; if(Type.GetType ("Mono.Runtime") != null) LIST0.Add("mono"); LIST0.Add(server); LIST0.Add("--prefix"); LIST0.Add("s"); // create the object 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()); c00.LinkCreateChild (c0, "--postfix", "00" ); c01.LinkCreateChild (c0, "--postfix", "01" ); c000.LinkCreateChild (c00, "--postfix", "000" ); c1.LinkCreate(LIST1.ToArray()); c10.LinkCreateChild (c1, "--postfix", "10" ); c100.LinkCreateChild (c10, "--postfix", "100" ); c101.LinkCreateChild (c10, "--postfix", "101" ); // do the tests Console.WriteLine(c0.Get()); Console.WriteLine(c00.Get()); Console.WriteLine(c01.Get()); Console.WriteLine(c000.Get()); Console.WriteLine(c1.Get()); Console.WriteLine(c10.Get()); Console.WriteLine(c100.Get()); Console.WriteLine(c101.Get()); } catch (Exception ex) { c0.ErrorCatch(ex); } finally { // do the cleanup c1.LinkDelete(); c0.Exit(); } } } }
/** * @file NHI1/example/cs/testserver.cs * @brief testserver.cs - 26 Jun 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permission to copy, * please contact AUTHOR for additional information * @version 08a242faddae5101924d8fe811888e78892a82d9 * @date Wed Jun 26 14:26:21 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ using System; using csmqmsgque; namespace example { sealed class testserver : MqContextC, MqServerSetupIF { public testserver(MqContextC tmpl=null) : base(tmpl) { } public void GTCX () { SendSTART(); SendI32(LinkGetCtxId()); SendSTR("+"); if (LinkIsParent()) { SendI32(-1); } else { SendI32(LinkGetParent().LinkGetCtxId()); } SendSTR("+"); SendSTR(ConfigGetName()); SendSTR(":"); SendRETURN(); } void MqServerSetupIF.ServerSetup() { ServiceCreate("GTCX", GTCX); } static void Main(string[] argv) { testserver srv = MqFactoryCT<testserver>.Add().New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Exception ex) { srv.ErrorCatch (ex); } srv.Exit(); } } }