Android Question JobDone event does not fire (CKVS)

pesquera

Active Member
Licensed User
Longtime User
Hi,

I'm implementing CKVS on my own app, having this issue..

Debbuging that, I can figure it out that the Sub HandleQueue, into ClientKVS module, does never fire the JobDone event.. already checked that the local URL is good

Doing the same debug in the CloudKVS B4A example, it does work fine of course

In my app I have had to switch from OkHttpUtils2 to HttpUtils2.. can this be the problem?

I've switched this because I'm also using a HttpJob to send Push messages.. if left OkHttpUtils2, then I had this issue (SetContentType/SetHeader does not exist):
upload_2016-4-6_17-9-53.png


Also, I've tested the CloudKVS B4A example switching OkHttpUtils2 to HttpUtils2.. it does work Ok with both libraries

Mine does compile only with HttpUtils2, but does not fire JobDone.. how can I do? thanks!
 

pesquera

Active Member
Licensed User
Longtime User
thanks, with your help I figured out that I should have checked OkHttp instead of HTTP.. so, I have not that error any more and left referenced OkHttpUtils2 as in the example..
but, JobDone does not fire anyway :(

here is how does it look now:
upload_2016-4-6_17-57-54.png
 
Upvote 0

pesquera

Active Member
Licensed User
Longtime User
sure! is the same as the original ClientKVS Class.. plus some logs added

B4X:
Private Sub HandleQueue
Log("Sub HandleQueue")
Log("SendingJob=" & SendingJob)
    If SendingJob = True Then
Log("Return")
        Return
    End If
    Dim rs As ResultSet = sql.ExecQuery("SELECT qid, task, taskname FROM queue ORDER BY qid")
Log("rs.RowCount=" & rs.RowCount)
    If rs.NextRow Then
        Dim queue_id As Long = rs.GetLong("qid")
        Dim Job As HttpJob
        Job.Initialize("Job", Me)
        Job.PostBytes(url,rs.GetBlob("task"))
        Job.Tag = CreateMap("queue_id": queue_id, "taskname": rs.GetString("taskname"))
        SendingJob = True
    End If
    rs.Close
End Sub

Private Sub JobDone(job As HttpJob)
Log("Sub JobDone (ClientKVS) **********************************************")
Log("SendingJob=" & SendingJob)
Log("job.Success=" & job.Success)
    SendingJob = False
    If job.Success Then
        Dim m As Map = job.Tag
        Dim taskname As String = m.Get("taskname")
Log($"sending taskname: ${taskname}"$)
        Dim queue_id As Long = m.Get("queue_id")
        If taskname.StartsWith("getuser") Then
            Dim ser As B4XSerializator
            ser.Tag = m
            ser.ConvertBytesToObjectAsync(Bit.InputStreamToBytes(job.GetInputStream), "ser")
        Else
            DeleteFromQueue(queue_id)
            HandleQueue
        End If
    Else
        Log($"Error sending task: ${job.ErrorMessage}"$)
        csu.CallSubDelayedPlus(Me, "HandleQueue", 30000)
    End If
    job.Release
End Sub
 
Upvote 0

pesquera

Active Member
Licensed User
Longtime User
SOLVED! on Starter service, moved Initialization from Service_Create to Service_Start

B4X:
If Not(ckvs.IsInitialized) Then
... then Initialite CKVS

thanks!!
 
Upvote 0

pesquera

Active Member
Licensed User
Longtime User
FYI: the problem was only in debug mode.. I noticed that switching to release mode all is fine, so moved again to Service_Create
I call CKVS.Put right after initializing CKVS, on Starter.. may be is something with the timing, or something else.. I don't know, but.. now is working!
thanks
 
Upvote 0
Top