• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Interview Question in a reputed investment bank on transaction.

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I went to an interview with a reputed investment bank I was asked a question on transaction as below

' Your transaction involves two parts : a JMS message generation and a DB operation. you have sent the message to the JMS provider and Database insert fails then how you are going to manage transaction?'

Please help find an answer to this question..

Regards

Guy
 
author
Posts: 23850
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Was the word "transaction" actually used in the question? If so, then I will speculated that this was a leading question, and the interviewer wanted to discuss "transactions".

Transactions are optionally supported by both JMS and Databases (JDBC), and the interviewer probably wanted you to discuss such support. Additionally, since two different systems that support transactions, was mentioned, the interview probably wanted you to discuss the concept of "two phase commit".

Henry
 
Guy Emerson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry for your insights.

Was the word "transaction" actually used in the question?



Yes it was asked the way I narrated in my post.

Additionally, since two different systems that support transactions, was mentioned, the interview probably wanted you to discuss the concept of "two phase commit".



Would you help explain how one would apply a Two phase commit in a method that involves a JMS message sending and a DB insert. if the DB insert fails the JMS message should also be rollbacked. This would be great insight for me as well as a lot of others to better their comprehension on this topic.

Regards

Guy
 
Marshal
Posts: 24812
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ideally you would be working in an environment which already supports distributed transactions, so you wouldn't exactly be using two-phase commit in the sense of writing your own transaction-managing code. You'd just use the built-in facilities of the transaction manager that's already there.

Now having said that, I don't know the details of that because I haven't ever had to deal with it. But basically you start a transaction, you ensure that your JMS facility is registered to participate in that transaction, you send the JMS message. Then you ensure that your JDBC driver is also registered with the transaction manager, you try to do the insert, it fails, and you roll back the transaction. That causes the JMS message to be not sent, or unsent, or however the transaction manager handles that.

I've heard of "two-phase commit", but I don't know how it works. That's the same as a large number of other concepts in the computing field -- I don't know how it works really and I don't have to know. So it's just a buzzword. But mentioning buzzwords does get you kudos even if you don't understand the details.
 
author & internet detective
Posts: 39755
797
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wikipedia has a pretty good description. I knew about the polling/voting, but not everything on that page. Because as Paul said, the driver handles the low level details
 
Ranch Hand
Posts: 406
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Now having said that, I don't know the details of that because I haven't ever had to deal with it. But basically you start a transaction, you ensure that your JMS facility is registered to participate in that transaction, you send the JMS message. Then you ensure that your JDBC driver is also registered with the transaction manager, you try to do the insert, it fails, and you roll back the transaction. That causes the JMS message to be not sent, or unsent, or however the transaction manager handles that.



Hi Paul,

I am just wondering that JMS and Database are two different systems, so, how they will be able to use the same transaction system to be in sync.. Any inputs will be highly appreciated. Thanks in advance.
 
Paul Clapham
Marshal
Posts: 24812
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vaibhav Gargs wrote:Hi Paul,

I am just wondering that JMS and Database are two different systems, so, how they will be able to use the same transaction system to be in sync.. Any inputs will be highly appreciated. Thanks in advance.



I can't imagine why you would ask me that after what I wrote in my last post.
 
brevity is the soul of wit - shakepeare. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!