i have 100 gps device sending coordinates periodically on every 10 seconds . customer want real time reverse geocoding see vehicles along location on tabular view. have set queue save packets in db before have added geocoding script below
receive tcp ip message using websocket
public function onmessage(connectioninterface $conn, $msg) { //get message // send dispatch job save in db $this->dispatch(new savepacketstodb($key_1, json_encode( array( 'company_id' => $key_1, 'vehicle_id' => $company->vehicle_id, 'tracker_id' => $company->tracker_id, 'lat' => $lat, 'lng' => $lng, 'imei' => $imei, 'datetime' => $datetime, ) )));
}
run queue
public function handle(){ $lat=$obj->lat; $lng=$obj->lng; $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . "," . $lng . "&key=mykey"; $json = file_get_contents($url); $data = json_decode($json); $status = $data->status; $address = ''; if ($status == "ok") { // echo "from geocode address"; echo $address = $data->results[0]->formatted_address; } else{ $address=null; } //save db }
i worried if works 1000 concurrent devices if include geocoding on queue, there better approach it?
Comments
Post a Comment