theLink 10.0
Loading...
Searching...
No Matches
MqMsgque_Main_RB_API

MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup …

+ Collaboration diagram for MqMsgque_Main_RB_API:

MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup …

Example from MyServer.rb The package-main configure the factory and start the server.

require "rbmqmsgque"
include MqMsgque

# package-item
class MyServer < MqContextC

  # factory startup
  def initialize()
    super
    ConfigSetServerSetup(method(:ServerSetup))
  end

  # define a service as link between the token "HLWO" and the callback "MyFirstService"
  def ServerSetup
    ServiceCreate("HLWO",method(:MyFirstService))
  end

  # service to serve all incoming requests for token "HLWO"
  def MyFirstService()
    SendSTART()
    SendSTR(ReadSTR() + " World")
    SendRETURN()
  end
end

# ====================================================
# package-main

# create the "MyServer" factory… and object
srv = MqFactoryC.Add(MyServer).New()

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