Traccar forwarding - sleep between forwarding each position

Hello,

I'm using Traccar server to act as a listener for Ruptela devices and forward the information to OpenGTS (using the grpmc servlet). Forwarding works great, but it would really be useful to me to:
Pause between positions sent (for each device separately), put the thread to sleep for a few seconds so that OpenGTS listener (gprmc) has enough time to orderly handle the data.
When a device sends out more than one position in the same connection (happens when vehicle is in motion) traccar forwards positions to gprmc servlet, gprmc servlet receives those positions and starts threads (which aren't thread safe), so total odometer calculations (totalOdometer += distance) end up wrong (more than one thread reads the same stored total odometer from DB), also pseudo status codes such as Start & Stop end up in the wrong place, for example: 1)Dormant 2)InMotion 3)Start, when it should be: 1)Dormant 2)Start 3)InMotion.

I know this can be avoided by instructing the grpmc servlet to be in single-thread model, however that would seriously slow down receiving of information (especially when I get even more devices). Another approach would be not to use variables that aren't thread safe, however OpenGTS version I have has been heavily modified...

I'm not familiar with Traccar code so if you could please point me out which Traccar java class(es) I need to modify I would be grateful.

Excuse me for the long post,
Kind regards,
V.Milankovic.

Anton Tananaev8 years ago

I would start with "WebDataHandler" class. That's the one that forwards the data. It might be possible to implement some per-device delay there.

Another option is "ExtendedObjectDecoder". That's where multiple positions are split into separate events.

Thank you very much for your help.

I'll see what I can do and posts the solution here (after testing it out thoroughly), in case somebody else needs this kind of thing.