Documentation of the Filter6 tool used for trans2.test
.
The Filer6 tool is used to test the filter-feature of csmqmsgque.
To run the filter test, a first client, one or more filters and a final server are created. All are connected to the csmqmsgque protocol.
The trans2.test
carries out common filter tests and special stress tests. A stress test is performed by exiting one or more filters or servers and observing the response and behavior when reconnecting.
The GOAL for this test is:
/** * @file NHI1/example/cs/Filter6.cs * @brief Filter6.cs - 23 Jul 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permission to copy, * please contact AUTHOR for additional information * @version e6ce5cfbf6c7dfb4f0b3eb45bb50508830143224 * @date Tue Jul 23 22:39:27 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ using System; using System.IO; using System.Collections.Generic; using System.Text.RegularExpressions; using csmkkernel; using csmqmsgque; namespace example { sealed class Filter6 : MqContextC, MqServerSetupIF, MqServerCleanupIF, MqEventIF { private Regex rgx = null; private MkLogFileC FH = null; public Filter6(MqContextC tmpl=null) : base(tmpl) { ConfigSetIgnoreExit(true); rgx = new Regex("^(?:Filter6-1|Filter6|fs1.*)$"); } void ErrorWrite () { var err = ErrorFORMAT(); FH.WriteC("ERROR: " + err.GetText()); err.Reset(); } void LOGF () { MqContextC ftr = SlaveGetFilter(); if (rgx.IsMatch(ftr.ConfigGetName())) { FH = MkLogFileC.Open(this,ReadSTR()); } else { ProxyForward(ftr); } SendRETURN(); } static void WRIT (MqContextC ctx) { var master = (Filter6) ctx.SlaveGetMaster(); if (master.rgx.IsMatch(master.ConfigGetName())) { master.FH.WriteC(ctx.ReadSTR()); } else { ctx.ProxyForward(master); } ctx.SendRETURN(); } void EXIT () { Exit(); } void SOEX () { ErrorFORMAT().SetEXIT(); } void FilterIn () { StorageExport(); SendRETURN(); } void MqEventIF.Event () { if (StorageCount() == 0L) { ErrorFORMAT().SetCONTINUE(); } else { int Id = 0; try { MqContextC ftr = SlaveGetFilter(); Id = StorageImport(); try { ProxyForward(ftr); } catch (MkExceptionC) { if (StorageErrCnt(Id) <= 3) { StorageDecrRef(Id); return; } else { throw; } } catch { throw; } } catch (Exception ex) { ErrorCatch (ex); ErrorWrite(); } Id = StorageDelete(Id); } } void MqServerCleanupIF.ServerCleanup() { if (FH == null) return; FH.Dispose(); FH = null; } /// [filter_service_example] void MqServerSetupIF.ServerSetup() { MqContextC ftr = SlaveGetFilter(); ServiceCreate ("LOGF", LOGF); ServiceCreate ("EXIT", EXIT); ServiceCreate ("SOEX", SOEX); ServiceCreate ("+ALL", FilterIn); ServiceStorage ("PRNT"); ServiceStorage ("PRN2"); ftr.ServiceCreate ("WRIT", Filter6.WRIT); ServiceCreate ("WRIT", Filter6.WRIT); ftr.ServiceProxy ("WRT2", (int)MqSlaveE.MASTER); } /// [filter_service_example] /// [error_example] public static void Main(string[] argv) { Filter6 srv = MqFactoryCT<Filter6>.Add().New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Exception ex) { srv.ErrorCatch (ex); } srv.Exit(); } /// [error_example] } }