Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active September 16, 2019 21:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AdamBien/a47834f9c6dc4f85fe2de58084ac0246 to your computer and use it in GitHub Desktop.
66thAirhacksQ&A.md

Ask questions and see you at September, 2nd, 6.PM. CET: http://www.ustream.tv/channel/adambien

Also checkout recent episode:

65th airhacks.tv

Please keep the questions Java EE-stic. Means: as short and as concise as only possible. Feel free to ask several, shorter questions.

@t-shaguy
Copy link

t-shaguy commented Sep 2, 2019

Hi Adam,

Please do you advice developing a securities trading solution in PHP? I mean is PHP battle tested enough for this. I am trying to justify a move to java but its a battle convincing the business team. Please advice me on best ways to.

@fblan
Copy link

fblan commented Sep 16, 2019

Hi Adam,

we have a business constraint that a value should not drop below 0. The value is calculated on the fly based on a set of entries. We offer a JAX-RS endpoint to allow adding entries but if the account drops below 0. Imagine just a basic bank account where you have 50€ and you can book as long you have enough funds on your account.

Some clients started to replay their POST requests and dropped below 0€ because of race conditions,
because when the request was posted they had enough funds. How can you prevent that? Obviously, we told the clients to stop that, but we want to protect the business constraints on our side, too.

Love from Essen, DE

Hi Adam, do you think it is possible to use database to check race condition? a request looking like :

begin transaction
Query query = em.createQuery(
"UPDATE Account SET amount=amount-:removedAmount WHERE id=:id and amount>:removedAmount");
query.setParameter("id", accountid);
query.setParameter("removedAmount",105);
int updateCount = query.executeUpdate();
transaction commit
if(updateCount==1){
return 'success';
}

do you think this could work?

Thanx a lot for your podcast :)

Fred

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment