Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interview Question in a reputed investment bank on transaction.

 
Guy Emerson
Ranch Hand
Posts: 41
  • 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
 
Henry Wong
author
Marshal
Pie
Posts: 22116
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor 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: 41
  • 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
 
Paul Clapham
Sheriff
Posts: 21576
33
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • 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
 
Vaibhav Gargs
Ranch Hand
Posts: 40
  • 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
Sheriff
Posts: 21576
33
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic