vbmqmsgque 9.0
Loading...
Searching...
No Matches
Example: perfserver

Documentation of the perfserver tool used for example.test.

INTRODUCTION

The perfserver tool is used server-part of the performance-test

To perform the test the perfclient send various service request to the perfserver. The perfclient is written in C and finally create a report.

All context created, are connected using the vbmqmsgque protocoll and build together a flat-like structure.

The GOAL for this setup is:

CODE server

REM
REM   @file         example/vb/perfserver.vb
REM   @brief        perfserver.vb - 03 May 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      1c3a8f89f6bbd5c146252125f8a426400f6e1300
REM   @date         Wed May 3 12:28:13 2023 +0200
REM   @author       aotto1968 <aotto1968@t-online.de>
REM

Imports System
REM Imports System.Linq
Imports csmsgque.mkkernel
Imports csmsgque.mqmsgque

Public Module example

  Private NotInheritable Class perfserver
    Inherits MqContextC
    Implements IServerSetup

    ' factory constructor
    Public Sub New (Optional ByVal tmpl As MqContextC = Nothing)
      MyBase.New(tmpl)
    End Sub

    Private Sub ECOU () 
      SendSTART()
      SendU(ReadU())
      SendRETURN()
    End Sub

    Private Sub ECOI ()
      SendSTART()
      SendI(ReadI())
      SendRETURN()
    End Sub

    Private Sub ECUL ()
      SendSTART()
      SendY(ReadY())
      SendS(ReadS())
      SendI(ReadI())
      SendD(ReadD())
      ProxyItem(Me)
      SendRETURN()
    End Sub

    Private Sub RDUL ()
      ReadY()
      ReadS()
      ReadI()
      ReadD()
      ReadU()
    End Sub

    Private Sub RDUC ()
      ReadC()
      ReadC()
      ReadC()
      ReadC()
      ReadC()
    End Sub

    Private Sub STDB ()
      SendSTART()
      StorageOpen(ReadC())
      SendRETURN()
    End Sub

    Private Sub STDC ()
      SendSTART()
      StorageClose()
      SendRETURN()
    End Sub

    ' [BufferStream-Create-TLS]
    Private Sub BUST ()
      Dim bus As MkBufferStreamC = MkBufferStreamC.CreateTLS(0)
      While ReadItemExists()
        bus.WriteU(ReadU())
      End While
      bus.PosToStart()
      SendSTART()
      While bus.ReadItemExists()
        SendU(bus.ReadU())
      End While
      SendRETURN()
    End Sub
    ' [BufferStream-Create-TLS]

    ' [BufferList-Create-TLS]
    Private Sub BFLT ()
      Dim bfl As MkBufferListC = MkBufferListC.CreateTLS(0)
      While ReadItemExists()
        bfl.AppendU(ReadU())
      End While
      SendSTART()
      For i As Integer = 0 To bfl.Size()-1
        SendU(bfl.IndexGet(i))
      Next
      SendRETURN()
    End Sub
    ' [BufferList-Create-TLS]

    Private Sub BINT ()
      ReadB()
    End Sub

    Private Sub STRT ()
      ReadC()
    End Sub

    ' define a service as link between the token "HLWO" and the callback "MyFirstService"
    Private Sub ServerSetup() Implements IServerSetup.ServerSetup
      ServiceCreate("ECOU", AddressOf ECOU)
      ServiceCreate("ECOI", AddressOf ECOI)
      ServiceCreate("ECUL", AddressOf ECUL)
      ServiceCreate("RDUL", AddressOf RDUL)
      ServiceCreate("RDUC", AddressOf RDUC)
      ServiceCreate("STDB", AddressOf STDB)
      ServiceCreate("STDC", AddressOf STDC)
      ServiceCreate("BUST", AddressOf BUST)
      ServiceCreate("BFLT", AddressOf BFLT)
      ServiceCreate("BINT", AddressOf BINT)
      ServiceCreate("STRT", AddressOf STRT)
    End Sub
  End Class

  Sub Main(ByVal argv() As String)
    ' setup commandline arguments for later use
    Dim largv As New MkBufferListC(argv)

    ' [factory-item]
    ' create "perfserver" factory… and make it to the default.
    MqFactoryC.Add(GetType(perfserver)).Default()
    ' [factory-item]

    ' inspect commandline-argument for the "factory" to choose… and create a object
    Dim srv As MqContextC = MqFactoryC.GetCalled(largv).[New]()

    Try
      srv.LinkCreate(largv)
      srv.ProcessEvent(MqWaitOnEventE.FOREVER)
    Catch ex As Exception
      srv.ErrorCatch(ex)
    End Try
    srv.Exit()
  End Sub
End Module