rbmqmsgque 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 rbmqmsgque.

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

The GOAL for this setup is:

CODE client

#+
#:   @file         example/ruby/testclient.rb
#:   @brief        testclient.rb - 20 Oct 2022 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      eca2a2ee05f368470d4127d36503bd9e26063147
#:   @date         Thu Oct 20 14:18:44 2022 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:
require "rbmqmsgque"
include PyMsgque::MqMsgque
## setup the clients
server = File.join(File.dirname($0), "testserver.rb")
## create object
c0 = MqContextC.new
c00 = MqContextC.new
c01 = MqContextC.new
c000 = MqContextC.new
c1 = MqContextC.new
c10 = MqContextC.new
c100 = MqContextC.new
c101 = MqContextC.new
## setup object link
c0.LinkCreate(            "c0",    "--postfix", "0",      "--prefix", "c", "--debug", ENV['TS_DEBUG'], 
                                                          "@", ENV['RUBY'], server, "--prefix", "s")
c00.LinkCreateChild(c0,   "c00",   "--postfix", "00"  )
c01.LinkCreateChild(c0,	  "c01",   "--postfix", "01"  )
c000.LinkCreateChild(c00, "c000",  "--postfix", "000" )
c1.LinkCreate(            "c1",    "--postfix", "1",      "--prefix", "c", *ARGV)
c10.LinkCreateChild(c1,   "c10",   "--postfix", "10"  )
c100.LinkCreateChild(c10, "c100",  "--postfix", "100" )
c101.LinkCreateChild(c10, "c101",  "--postfix", "101" )
## my helper
def Get(ctx)
  ret = ""
  ctx.SendSTART()
  ctx.SendEND_AND_WAIT("GTCX")
  ret += ctx.ConfigGetName()
  ret += "+"
  ret += ctx.ReadC()
  ret += ctx.ReadC()
  ret += ctx.ReadC()
  ret += ctx.ReadC()
  ret += ctx.ReadC()
  ret += ctx.ReadC()
  return ret
end
## do the tests
$stdout.puts(Get(c0))
$stdout.puts(Get(c00))
$stdout.puts(Get(c01))
$stdout.puts(Get(c000))
$stdout.puts(Get(c1))
$stdout.puts(Get(c10))
$stdout.puts(Get(c100))
$stdout.puts(Get(c101))
$stdout.flush
## do the cleanup
c1.LinkDelete()
c0.Exit()

CODE server

#+
#:   @file         example/ruby/testserver.rb
#:   @brief        testserver.rb - 20 Oct 2022 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      eca2a2ee05f368470d4127d36503bd9e26063147
#:   @date         Thu Oct 20 14:18:44 2022 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:

require "rbmqmsgque"
include PyMsgque::MqMsgque

class TestServer < MqContextC
  def initialize()
    ConfigSetServerSetup(method(:ServerSetup))
    super()
  end
  def GTCX
    SendSTART()
    SendI(LinkGetCtxId())
    SendC("+")
    if (LinkIsParent())
      SendI(-1)
    else
      SendI(LinkGetParent().LinkGetCtxId())
    end
    SendC("+")
    SendC(ConfigGetName())
    SendC(":")
    SendRETURN()
  end
  def ServerSetup
    ServiceCreate("GTCX",method(:GTCX))
  end
end

srv = MqFactoryC.Add(TestServer).New()
begin
  srv.LinkCreate(ARGV)
  srv.ProcessEvent(MqWaitOnEventE::FOREVER)
rescue Exception => ex
  srv.ErrorCatch(ex)
ensure
  srv.Exit()
end