Hi all,
today I installed B4J 5.00 and recompiled an "old" test of mine about using MQQTBroker as a testing broker.
I'd like the idea of placing an Application_Error log somewhere just to be alerted about release mode errors, but couldn't find the way to integrate it in my test code.
Please find below the whole "broker" code.
Should I add a Server object just to be able to use Application_Error?
A different question is: where the error log is written to? Yes, I read about StdError and in Linux I will redirect StdErr to a text file, but what am I expected to do on a Windows Server where the jar is launched by double-clicking on its name? Should I write a batch for launching it by command line?
TIA
udg
today I installed B4J 5.00 and recompiled an "old" test of mine about using MQQTBroker as a testing broker.
I'd like the idea of placing an Application_Error log somewhere just to be alerted about release mode errors, but couldn't find the way to integrate it in my test code.
Please find below the whole "broker" code.
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Dim broker As MqttBroker
End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
'If srvr.CurrentThreadIndex = 0 Then 'main thread
LogError(StackTrace)
Return False
'Else 'handlers threads
' Return True
'End If
End Sub
Sub AppStart (Args() As String)
'record broker PID assigned on server
Dim jo As JavaObject
jo.InitializeStatic("java.lang.management.ManagementFactory")
Dim pid As String = jo.RunMethodJO("getRuntimeMXBean",Null).RunMethod("getName",Null)
File.WriteString(File.DirApp,"brokerpid.txt","EggBroker: "& pid.SubString2(0,pid.IndexOf("@")))
'set and start the broker
broker.Initialize("", 51212) 'first parameter is the event name. It is currently not used.
broker.SetUserAndPassword("tstuser","tstpwd*")
broker.Start
StartMessageLoop 'Non-UI app
End Sub
A different question is: where the error log is written to? Yes, I read about StdError and in Linux I will redirect StdErr to a text file, but what am I expected to do on a Windows Server where the jar is launched by double-clicking on its name? Should I write a batch for launching it by command line?
TIA
udg