vbmqmsgque 9.0
Loading...
Searching...
No Matches
Example: Identification-Test

Documentation of the Test-Client-Server tool used for example.test.

INTRODUCTION

The Naming-Test-Tool tool is used to test the name-resolution-feature of vbmqmsgque.

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 --postfix argument to identify unique.

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 vbmqmsgque protocoll and build together a flat structure.

The GOAL for this setup is:

CODE client

REM
REM   @file         example/vb/testclient.vb
REM   @brief        testclient.vb - 28 Dec 2022 - aotto1968
REM   @copyright    (C) NHI - #1 - Project - Group
REM                 This software has NO permissions to copy,
REM                 please contact AUTHOR for additional information
REM   @version      58c0906861433dfd14a652ce3c9dcc4185d054e6
REM   @date         Wed Dec 28 15:20:47 2022 +0100
REM   @author       aotto1968 <aotto1968@t-online.de>
REM

Imports System
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Imports System.Reflection
Imports csmsgque.mqmsgque

Public Module example

  Private NotInheritable Class testclient
    Inherits MqContextC

    Public Function GetV() As StringBuilder
      Dim RET As New StringBuilder()
      SendSTART()
      SendEND_AND_WAIT("GTCX")
      RET.Append(ConfigGetName())
      RET.Append("+")
      RET.Append(ReadC())
      RET.Append(ReadC())
      RET.Append(ReadC())
      RET.Append(ReadC())
      RET.Append(ReadC())
      RET.Append(ReadC())
      Return RET
    End Function
  End Class

  Sub Main(ByVal argv() As String)
    Dim dirname As String = New FileInfo(Assembly.GetEntryAssembly().Location).DirectoryName
    Dim server As String = Path.Combine(dirname, "testserver.exe")
    Dim LIST1 As New List(Of String)(New String() {"--prefix", "c", "--postfix", "1"})
    LIST1.AddRange(argv)
    Dim LIST0 As New List(Of String)(New String() {
      "--prefix", "c", "--postfix", "0", "--debug", System.Environment.GetEnvironmentVariable("TS_DEBUG"), "@"
    })
    If (Type.GetType ("Mono.Runtime") IsNot Nothing)
      LIST0.Add("mono")
    End If
      LIST0.Add(server)
      LIST0.Add("--prefix")
      LIST0.Add("s")

    ' setup the clients
    Dim c0 As New testclient()
    Dim c00 As New testclient()
    Dim c01 As New testclient()
    Dim c000 As New testclient()
    Dim c1 As New testclient()
    Dim c10 As New testclient()
    Dim c100 As New testclient()
    Dim c101 As 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.GetV())
      Console.WriteLine(c00.GetV())
      Console.WriteLine(c01.GetV())
      Console.WriteLine(c000.GetV())
      Console.WriteLine(c1.GetV())
      Console.WriteLine(c10.GetV())
      Console.WriteLine(c100.GetV())
      Console.WriteLine(c101.GetV())
    Catch ex As Exception
      c0.ErrorCatch(ex)
    Finally
      ' do the cleanup
      c1.LinkDelete()
      c0.Exit()
    End Try
  End Sub

End Module

CODE server

REM
REM   @file         example/vb/testserver.vb
REM   @brief        testserver.vb - 02 Jan 2023 - aotto1968
REM   @copyright    (C) NHI - #1 - Project - Group
REM                 This software has NO permissions to copy,
REM                 please contact AUTHOR for additional information
REM   @version      1ea357d6e6ff098b256c68701c0a27d27faec290
REM   @date         Mon Jan 2 23:27:26 2023 +0100
REM   @author       aotto1968 <aotto1968@t-online.de>
REM

Imports System
Imports csmsgque.mqmsgque

Public Module example
  Private Class testserver
    Inherits MqContextC
    Implements IServerSetup
    
    ' constructor
    Public Sub New(Optional ByVal tmpl As MqContextC = Nothing)
      MyBase.New(tmpl)
    End Sub

    Private Sub GTCX()
      SendSTART()
      SendI(LinkGetCtxId())
      SendC("+")
      If LinkIsParent() Then
        SendI(-1)
      Else
        SendI(LinkGetParent().LinkGetCtxId())
      End If
      SendC("+")
      SendC(ConfigGetName())
      SendC(":")
      SendRETURN()
    End Sub

    Private Sub ServerSetup() Implements IServerSetup.ServerSetup
      ServiceCreate("GTCX", AddressOf GTCX)
    End Sub
  End Class

  Sub Main(ByVal args() As String)
    Dim srv As testserver = MqFactoryC.Add(GetType(testserver)).[New]()
    Try
      srv.LinkCreate(args)
      srv.ProcessEvent(MqWaitOnEventE.FOREVER)
    Catch ex As Exception
      srv.ErrorCatch(ex)
    End Try
    srv.Exit()
  End Sub
End Module