Documentation of the Filter6 tool used for trans2.test
.
The Filer6 tool is used to test the filter-feature of jvmqmsgque.
To run the filter test, a first client, one or more filters and a final server are created. All are connected to the jvmqmsgque 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/jv/Filter6.java * @brief Filter6.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.Queue; import java.util.LinkedList; import java.util.regex.Matcher; import java.util.regex.Pattern; import jvmsgque.mqmsgque.*; import jvmsgque.mkkernel.*; class Filter6 extends MqContextC implements IServerSetup, IServerCleanup, IEvent { private Pattern rgx = null; private MkLogFileC FH = null; public Filter6(MqContextC tmpl) { super(tmpl); ConfigSetIgnoreExit(true); rgx = Pattern.compile("^(?:Filter6-1|Filter6|fs1.*)$"); } private void ErrorWrite() { MkErrorC err = ErrorFORMAT(); try { FH.WriteC("ERROR: " + err.GetText()); } catch (Throwable ex) { err.Catch(ex).Println(); } finally { err.Reset(); } } private class LOGF implements MqServiceIF { public void Callback(MqContextC ctx) { MqContextC ftr = SlaveGetFilter(); if (rgx.matcher(ftr.ConfigGetName()).matches()) { FH = MkLogFileC.Open(Filter6.this,ReadSTR()); } else { ProxyForward(ftr); } SendRETURN(); } } private class WRIT implements MqServiceIF { public void Callback(MqContextC ctx) { var master = (Filter6) ctx.SlaveGetMaster(); if (master.rgx.matcher(ctx.ConfigGetName()).matches()) { master.FH.WriteC(ctx.ReadSTR()); } else { ctx.ProxyForward(master); } ctx.SendRETURN(); } } private class EXIT implements MqServiceIF { public void Callback(MqContextC ctx) { Exit(); } } private class SOEX implements MqServiceIF { public void Callback(MqContextC ctx) { ErrorFORMAT().SetEXIT(); } } private class FilterIn implements MqServiceIF { public void Callback(MqContextC ctx) { StorageExport(); SendRETURN(); } } public void Event() { if (StorageCount() == 0L) { ErrorFORMAT().SetCONTINUE(); } else { int Id = 0; try { MqContextC ftr = SlaveGetFilter(); Id = StorageImport(); try { ProxyForward(ftr); } catch (MkExceptionC ex) { int errCnt = StorageErrCnt(Id); if (errCnt < 3) { StorageDecrRef(Id); return; } else { throw ex; } } catch (Throwable ex) { throw ex; } } catch (Throwable ex) { ErrorCatch (ex); ErrorWrite(); } Id = StorageDelete(Id); } } public void ServerCleanup() { if (FH == null) return; FH.Dispose(); FH = null; } // [filter_service_example] public void ServerSetup() { MqContextC ftr = SlaveGetFilter(); ServiceCreate ("LOGF", new LOGF()); ServiceCreate ("EXIT", new EXIT()); ServiceCreate ("SOEX", new SOEX()); ServiceCreate ("+ALL", new FilterIn()); ServiceStorage ("PRNT"); ServiceStorage ("PRN2"); ftr.ServiceCreate ("WRIT", new WRIT()); ServiceCreate ("WRIT", new WRIT()); ftr.ServiceProxy ("WRT2", MqSlaveE.MASTER.get()); } // [filter_service_example] /// [error_example] public static void main(String[] argv) { MqContextC srv = MqFactoryC.Add(Filter6.class).New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Throwable e) { srv.ErrorCatch(e); } finally { srv.Exit(); } } /// [error_example] }