B4J Question [SOLVED] Weird behavior with Http_Job with non_UI B4J app running in Release mode

JackKirk

Well-Known Member
Licensed User
Longtime User
I have been using Http_Job forever with B4J/A/i to work with various AWS services (S3, Rekognition, Translate etc)- but always (in the case of B4J) with UI apps.

I am now playing with ABMaterial that requires use of a non-UI app to accommodate jServer.

When I run this app in Debug mode it all works fine.

When I run it in Release mode it fails - generally completely but sometimes intermittently.

After annoying the bejesus out of AWS technical support I started to suspect some timing problem - well some would have fallen to this immediately but I'm slow on the uptake.

After digging around with Log statements all over the place I found that if I modify Http_Job with:

B4X:
'<<jk
#If B4J
    Sleep(1)
#End If
'<<jk

    CallSubDelayed2(Http_Utils2_Service, "SubmitJob", Me)

Where ever CallSubDelayed2(Http_Utils2_Service, "SubmitJob", Me) appears then the problem goes away.

The one exception to this is don't do it in the Complete sub - get an infinite loop.

Am I missing something? Is there a more elegant solution? Any relevant thoughts?
 
Last edited:

JackKirk

Well-Known Member
Licensed User
Longtime User
No - didn't know it existed - sure looks like the more appropriate solution - my solution was blowing up when I ran it on a faster AWS EC2 instance with sporadic "java.lang.RuntimeException: java.lang.RuntimeException: Resumable sub already completed" errors

I will try it out tomorrow and report back - outstanding support as usual - thanks.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User

Sleep(1) in a console app exits if there is no StartMessageLoop. Check the tutorial by @Erel where it does something like this:
B4X:
Sub FirstSub

SecondSub
StartMessageLoop
Log("Done")
StopMessageLoop

'Do something like this now for httpjob
ThisIsForHttpJob
StartMessageLoop
Log("Done")
StopMessageLoop
End Sub

Sub SecondSub
Sleep(1)
End Sub

'Do something like this
Sub ThisIsForHttpJob
CallSubDelayed2(Http_Utils2_Service, "SubmitJob", Me)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…