symfony - Doctrine's persisted data is NOT accessible by other queries immediately -


i using beanstalkd task queue in order postpone heavy doctrine operations, can reproduced in other similar system rabbitmq, etc.

client (producer) side

$entitymanager = $this->getdoctrine()->getmanager();  $productentity = new product(); $productentity->setdata('somedata');  $entitymanager->persist($productentity);  // method blocking, right? execution not continue until  // data inserted database $entitymanager->flush();   // @ point data should in database // $productentity->getid() returns valid auto-incremented integer // pass job task queue, executed in worker $beanstalkdservice->put(     json_encode([         'command'=>'some:heavy:task',          'product_id' => $productentity->getid()     ) ); 

worker daemon (long running process on same server)

$entitymanager = $this->getdoctrine()->getmanager(); while(true){     $job = json_decode($beanstalkd->reserve());      if ($job['command'] === 'some:heavy:task'){         $productentity = $entitymanager->find('\path\to\product, $job['product_id']);     } } 

the line $entitymanager->find('\path\to\product, $job['product_id']); returns null if executed immediately

however

if add small delay before execution, like

sleep(1); $entitymanager->find('\path\to\product, $job['product_id']); 

then entity returned supposed to!

why record not accessible without delay? isn't flush() method blocking, execution not continue unless record inserted database?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -