java - At what point can I trust that data has been saved to mysql? -


after create new object 'order', generated id , put on amqp queue, worker can other stuff it. worker takes generated id (message) , looks order complains no record exists, though created one. trying figure out either how long wait after call .persist() before put message (generated id) on queue (which dont think idea); have worker loop on , on until mysql return record (which dont either); or find point can put message on queue after know data safe in mysql (this sounds best). im thinking needs done outside of @transactional method.

the worker going read data out of mysql part of different system on different server. when can tell worker data in mysql can started task?

is true after @transactional method finishes data done being written mysql, having trouble understanding this. million in advanced.

is true after @transactional method finishes data done being written mysql, having trouble understanding this. million in advanced.

so first, kayamann , ralf wrote in comments, guaranteed data stored , available other processes when transaction commits (ends)

@transactional methods easy understand. when have @transactional method, means container (application going invoke method) begin transaction before method invoked, , auto commit or rollback transaction in case of success or error.

so if have

@transactional public void modify(){    dosomething(); } 

and when call somewhere in code (or invokation via contaier eg due bindings) actuall frol follows

tx=entitymanager.begintransaction(); object.modify(); tx.commit(); 

there quite simple. such approach mean transactions container controlled

as 4 situation, let external system know transaction has been complete, have either use message queue (that using already) message transaction complete id , can start processing stuff, or use different technology, rest example.

remote systems can signal eachoter various of events via queues , rest services, there no difference.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -