Private NotInheritable Class MyClass Inherits MqS End Class Sub Main(ByVal args() As String) Dim ctx AS New MyClass() End Sub
MqConfig... or by using command-line arguments.PATH and additional arguments like a script name or required startup options. The startup-prefix is used for two different purpose:The startup-prefix is initially set by vbmsgque during package loading.
Integer, get: ConfigGetBuffersize , set: ConfigSetBuffersizeThe send and receive buffersize in bytes (default: 4KB)
Integer, get: ConfigGetDebug , set: ConfigSetDebugDebug a message-queue application. Valid values are 0 <= NUM <= 9 using 0 for "no debugging" and 9 for "maximum debugging". (default: 0)
Integer, get: ConfigGetTimeout , set: ConfigSetTimeoutUser defined timeout used for connection setup and data sending (default: 90 seconds)
String, get: ConfigGetName , set: ConfigSetNameUse STRING as basename of the new message-queue object. The name shows up in the debugging output and is used as prefix for the new created command. (default: the name of the executable)
String, get: ConfigGetSrvName , set: ConfigSetSrvNameUse STRING as a client specific prefix in the server debugging output. This is used to link debugging and error messages on the server to a specific client connection. (default: empty)
Boolean, get: ConfigGetIsSilent , set: ConfigSetIsSilentWrite (false) or don't write (true) any output to stdout or stderr. (default: write to stdout or stderr)
Boolean, get: ConfigGetIsString , set: ConfigSetIsStringUse (true), as much as possible, strings in the data-package. Convert any native data-type, like integer or double, into a string (sending) and back to native (receiving). (default: use binary)
Integer, get: ConfigGetStartAs , set: ConfigSetStartAs (startAs)Start a new server as thread or spawn a new process or fork a new process. This arguments are used with:
| [in] | startAs | 0=default, 1=fork, 2=thread and 3=spawn |
String, get: ConfigGetIoTcpHost/Port/MyHost/MyPort , set: ConfigSetIoTcp (host, port, myhost, myport)Configure a tcp socket link.
| host | client: name of the remote host (default: localhost) server: name of the local interface (default: listen on all interfaces) | |
| port | client: name of the remote port server: name of the local port | |
| myhost | client: name of the local interface | |
| myport | client: name of the local port |
String, get: ConfigGetIoUdsFile , set: ConfigSetIoUds (file)Use a uds (http://en.wikipedia.org/wiki/Unix_domain_socket) socket link. The uds communication is usually 50% faster than a local tcp communication but only available on UNIX.
| [in] | file | the name of the uds file |
Integer, get: ConfigGetIoPipeSocket , set: ConfigSetIoPipe (socket)Start a pipe server to listen on socket. This is the default mode to start a server. The socket option is special because it is used for internal purpose to submit the socket from the client to the server started as pipe by the client.
| [in] | socket | the file-descriptor number. The only public usage for this option is to serve as interface for an existing tool like (x)inetd. The (x)inetd tool is a UNIX service to listen on a tcp/ip port and start for every connection the proper entry from the file /etc/(x)inetd.conf with the file-descriptor 0 as send/recv socket handle. |
MqS, get: ConfigGetMaster , set: SLAVE OBJECTreturn the master if ctx is a slave-context or NULL if ctx is not a slave-context. !Only a SLAVE has a master!
Integer, get: ConfigGetCtxId , set: NO
return an identifier as integer and is unique per parent-context. The parent-context is always 0 and every new child-context get a new identifier by adding 1.
String, get: ConfigGetToken , set: NOreturn the current TOKEN IDENTIFIER and is only useful in a service callback. This command is needed on the server to implement a generic service (A ctx.ServiceCreate(String token, AddressOf service) with different TOKEN IDENTIFIER but with the same service callback).
Boolean, get: ConfigGetIsConnected , set: NOIs the vbmsgque context connected ? A context is connected if the ctx.LinkCreate(String() argv) command was successful and a context is NOT connected if a) the object has just been created or b) the link was deleted with ctx.LinkDelete()
Boolean, get: ConfigGetIsServer , set: IServerSetup or IServerCleanupTrue if object is a server object (default: false, be a client)
Boolean, get: ConfigGetIsParent , set: NOTrue if object is a parent object (default: true, be a parent)
Boolean, get: ConfigGetIsSlave , set: NOTrue if object is a slave object (default: false, not be a slave)
Interface, get: NO , set: csmsgque.IServerSetup.CallInterface to define a server vbmsgque object. This Interface define the ServerSetup callback called at ctx.LinkCreate(String() argv) to define the services or to initialize context specific variables. This interface set the isServer configuration value to true.
Interface, get: NO , set: csmsgque.IServerCleanup.CallInterface to define a server vbmsgque object. This Interface define the ServerCleanup callback called at ctx.LinkDelete() to free context specific variables. This interface set the isServer configuration value to true.
Interface, get: NO , set: csmsgque.IFilterFTR.CallInterface required to define a filter data stream object. This Interface define the IFilterFTR callback. The callback is used to act on filter data rows. Every filter input data is a list of filter data rows and every row is a list of filter data columns. Every row is send from one filter-command to the following filter-command as FTR service request. This interface set the isServer configuration value to true. (read more at: FILTER MODE)
Interface, get: NO , set: csmsgque.IFilterEOF.CallInterface required to define a filter data stream object. This Interface define the IFilterEOF callback. The callback is used to act on End-Of-Filter data and is called after all IFilterFTR data was send. Sometimes the filter data can not be served as IFilterFTR data (example: sorting of the input rows need to read all rows before the data can be send to the next filter command) and the IFilterEOF callback is used to continue send IFilterFTR data rows. This interface set the isServer configuration value to true. (read more at: FILTER MODE)
Interface, get: NO , set: csmsgque.IFactory.CallThe factory pattern is used to create a new application object (read more at: MqSetupS::Factory) Without the Factory pattern only the initial startup context is available to serve incoming requests. In general every server need to provide a Factory pattern.
Private NotInheritable Class Server Inherits MqS Implements IFactory Public Function Factory() As csmsgque.MqS Implements csmsgque.IFactory.Call Return New Server() End Function ... End Class
Interface, get: NO , set: csmsgque.IBgError.CallDefine an asyncrone error handler. This handler is used for handle errors send with ctx.SendERROR(). Use Integer ex.num or ctx.ErrorGetNum() and String ex.txt or ctx.ErrorGetText() to access the error.
| [in] | ctx | the object from OBJECT CREATION AND DELETION |
| [in] | args | command-line arguments including the "@" item for the --pipe setup |
| [in] | ctx | the object from OBJECT CREATION AND DELETION |
| [in] | parent | the parent object |
| [in] | args | all command-line arguments including the "@" token |
Public Sub ServerSetup() Implements csmsgque.IServerSetup.Call
ServiceCreate ("SRV1", AddressOf srv1);
End Sub
The callback is implemented using Interface: IService method Service(MqS ctx) or using a delegate of type Sub Callback().
| [in] | timeout | don't wait more than TIMEOUT seconds to get an answer from the server. If no answer is available an error is raised. (default: command-line: --timeout) |
| [in] | MqS.WAIT | use flag value to define the action (default: NO)
|
ctx.SendSTART() ctx.SendI(num) ctx.SendL_START() ctx.SendD(balance) ctx.SendC("name of the owner") ctx.SendB(signature) ctx.SendL_END() ctx.SendEND_AND_WAIT("SRV1")
num = ctx.ReadI() ctx.ReadL_START() balance = ctx.ReadD() owner = ctx.ReadC() signature = ctx.ReadB() ctx.ReadL_END()
| [in] | ctx | the master vbmsgque object as SERVER-PARENT without a CHILD |
| [in] | id | an integer used as unique identifer for the master/slave link |
| [in] | args | command-line arguments passed to the worker-client or the worker-server. all arguments prior the first @ token are added to the worker-client and the other arguments to the worker-server. |
ctx.SlaveCreate (7, "--thread", "--silent", "@", "WORKER", "--name", "MyWorker");
| [in] | ctx | the master vbmsgque object as PARENT without a CHILD |
| [in] | id | an integer used as unique identifer for the master/slave link |
| [in] | slave | the slave vbmsgque object as CLIENT-PARENT without a CHILD |
Dim buf As MqBufferS = ctx.ReadU() If buf.Type == "C"c Console.WriteLine(buf.C)
Y : 1 byte signed characterO : 1 byte boolean character using true for yes or true or false for no or wrongS : 2 byte signed shortI : 4 byte signed integerW : 8 byte signed long long integerF : 4 byte floatD : 8 byte doubleB : unsigned char array used for binary dataC : string data using a \0 at the endL : list type able to hold a list of all items from aboveU : typeless buffer able to hold a single item from above
Try i = ctx.ReadI() Catch ex As Exception ErrorSet(ex) Console.WriteLine(ErrorGetText()) ErrorReset() End Try
command1 | command2 | command3
msgcmd1 @ msgcmd2 @ msgcmd3
Imports System
Imports csmsgque
Public Module example
Private Class mulserver
Inherits MqS
Implements IServerSetup
Implements IFactory
Public Function Factory() As csmsgque.MqS Implements csmsgque.IFactory.Call
Return New mulserver()
End Function
Private Sub MMUL()
SendSTART()
SendD(ReadD() * ReadD())
SendRETURN()
End Sub
Public Sub ServerSetup() Implements csmsgque.IServerSetup.Call
ServiceCreate("MMUL", AddressOf MMUL)
End Sub
End Class
Sub Main(ByVal args() As String)
Dim srv As New mulserver()
Try
srv.ConfigSetName("MyMulServer")
srv.LinkCreate(args)
srv.ProcessEvent(MqS.WAIT.FOREVER)
Catch ex As Exception
srv.ErrorSet(ex)
Finally
srv.Exit()
End Try
End Sub
End Module
> mono mulserver.exe --tcp --port 7777 --thread
Imports System
Imports csmsgque
Public Module example
Sub Main(ByVal args() As String)
Dim ctx As New MqS()
Try
ctx.LinkCreate(args)
ctx.SendSTART()
ctx.SendD(3.67)
ctx.SendD(22.3)
ctx.SendEND_AND_WAIT("MMUL", 5)
Console.WriteLine(ctx.ReadD())
Catch ex As Exception
ctx.ErrorSet(ex)
Finally
ctx.Exit()
End Try
End Sub
End Module
> mono mulclient.exe --tcp --port 7777
Imports System
Imports csmsgque
Imports System.Collections.Generic
Public Module example
Private Class manfilter
Inherits MqS
Implements IFilterFTR
Public Sub FilterFTR() Implements csmsgque.IFilterFTR.Call
SendSTART()
While ReadItemExists()
SendC("<" + ReadC() + ">")
End While
SendFTR(10)
End Sub
End Class
Sub Main(ByVal args() As String)
Dim srv As New manfilter()
Try
srv.ConfigSetName("ManFilter")
srv.LinkCreate(args)
srv.ProcessEvent(MqS.WAIT.FOREVER)
Catch ex As Exception
srv.ErrorSet(ex)
Finally
srv.Exit()
End Try
End Sub
End Module
> echo -e "1:2:3\na:b:c" | atool split -d : @ mono manfilter.exe @ atool join -d :
1.5.8