In GlassFish 2.x, verifying the "cmt-timeout-in-seconds" setting in "sun-ejb-jar.xml"
My team is using the "cmt-timeout-in-seconds" setting, in the "sun-ejb-jar.xm开发者_如何学编程l" file on a GlassFish 2.x server, to control the transaction timeout threshold for an EJB module.
I realize that this is a pretty broad question... but we're having issues (I'm not sure of all the details myself), and I've been asked to verify that the "cmt-timeout-in-seconds" actually is being used.
Does anyone know of a way to interrogate or determine this from the application server, short of writing new custom code to test it? I'm not even certain what kind of custom code I would write if I had to go down that path.
It seems that the most straightforward answer is simply to write a small test case. I just created a simple EJB, with a custom CMT timeout setting in "sun-ejb-jar.xml
".
I then wrote a method on this EJB class, annotated to require its own new transaction. This method did three things: (1) write a log message, (2) use Thread.sleep()
to pause execution for awhile, and (3) write a second log message.
By using sleep values that were greater than or less than the CMT timeout setting, I was able to confirm that the settings were being applied.
However, one interesting note that I learned from this... when a container-managed transaction times-out for an EJB3 method, it does not interrupt or halt the execution of that method! The method continues to execute (or stays hung), and the consequences of the timeout are not handled and logged until after the method returns. Interesting behavior, which can lead to some serious bugs if you're not aware of it. See this article for more detail.
精彩评论