transaction rollback hook?

95 views
Skip to first unread message

David Moshal

unread,
Sep 4, 2010, 2:14:42 AM9/4/10
to play-fr...@googlegroups.com
Hi, am wondering if there is a hook for transactions which are
rollback, to do additional cleanup (for example to rollback a pending
message queue).

David

Julien Tournay

unread,
Sep 4, 2010, 6:12:40 AM9/4/10
to play-fr...@googlegroups.com
I don't know.
If you don't get an answer here, try to ask on hibernate's forum because if it's possible, it's likely not a Play feature.

Julien


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.




--
Real Programmers don't need comments-- the code is obvious.

GrailsDeveloper

unread,
Sep 4, 2010, 6:53:50 AM9/4/10
to play-framework
Perhaps you could add it as a feature to JPAPlugin?
registerRollbackListener?
And you could try to ask the question at stackoverflow.com with tags
for jpa, hibernate and playframework. I guess there are more readers,
so perhaps someone can give you there a smarter tip.

Niels

On 4 Sep., 12:12, Julien Tournay <boudhe...@gmail.com> wrote:
> I don't know.
> If you don't get an answer here, try to ask on hibernate's forum because if
> it's possible, it's likely not a Play feature.
>
> Julien
>
>
>
> On Sat, Sep 4, 2010 at 8:14 AM, David Moshal <dmos...@gmail.com> wrote:
> > Hi, am wondering if there is a hook for transactions which are
> > rollback, to do additional cleanup (for example to rollback a pending
> > message queue).
>
> > David
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "play-framework" group.
> > To post to this group, send email to play-fr...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > play-framewor...@googlegroups.com<play-framework%2Bunsu...@googlegroups.com>
> > .

DaveM

unread,
Sep 21, 2010, 3:18:16 AM9/21/10
to play-framework
Seems that this functionality is exposed in the Plugin api.

Perhaps I'll give that a go.

Dave

On Sep 4, 3:12 am, Julien Tournay <boudhe...@gmail.com> wrote:
> I don't know.
> If you don't get an answer here, try to ask on hibernate's forum because if
> it's possible, it's likely not a Play feature.
>
> Julien
>
> On Sat, Sep 4, 2010 at 8:14 AM, David Moshal <dmos...@gmail.com> wrote:
> > Hi, am wondering if there is a hook for transactions which are
> > rollback, to do additional cleanup (for example to rollback a pending
> > message queue).
>
> > David
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "play-framework" group.
> > To post to this group, send email to play-fr...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > play-framewor...@googlegroups.com<play-framework%2Bunsu...@googlegroups.com>
> > .

DaveM

unread,
Sep 21, 2010, 3:20:07 AM9/21/10
to play-framework
Hmm - now where is the plugin tutorial, one wonders?

On Sep 4, 3:12 am, Julien Tournay <boudhe...@gmail.com> wrote:
> I don't know.
> If you don't get an answer here, try to ask on hibernate's forum because if
> it's possible, it's likely not a Play feature.
>
> Julien
>
> On Sat, Sep 4, 2010 at 8:14 AM, David Moshal <dmos...@gmail.com> wrote:
> > Hi, am wondering if there is a hook for transactions which are
> > rollback, to do additional cleanup (for example to rollback a pending
> > message queue).
>
> > David
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "play-framework" group.
> > To post to this group, send email to play-fr...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > play-framewor...@googlegroups.com<play-framework%2Bunsu...@googlegroups.com>
> > .

GrailsDeveloper

unread,
Sep 21, 2010, 3:28:58 AM9/21/10
to play-framework
Unfortunately there isn't a Plugin-Tutorial, you only can have a look
at PlayPlugin-Api. But in you case it's not necessary to write a new
plugin, I think you must patch the JPAPlugin.
Niels

DaveM

unread,
Sep 21, 2010, 3:50:37 AM9/21/10
to play-framework
Let me explain why I think I need a plugin:

1) I'd like to embed the excellent object database objectdb

2) my application uses comet (reverse ajax) in which messages are
pushed to the browser.
However, these need to be synchronized with the transactions - ie: if
a transaction rollsback, then no messages are pushed out, ie, the
message handler needs to rollback to. If the transaction succeeds,
then the message handler flushes message to subscribing clients.

I just looked at the PlayPlugin class, seems straight forward to
extend, seems like the hooks to implement code before and after
invocations is there too.

Question :
I'm assuming that plugins need to be registered somewhere, and/or
bound to routes.
Any suggestions on how to make my plugin known to Play, and how to

David


On Sep 21, 12:28 am, GrailsDeveloper <opensourc...@googlemail.com>
wrote:

GrailsDeveloper

unread,
Sep 21, 2010, 4:43:08 AM9/21/10
to play-framework
Well if you want to do further thing in case of rollback, you must do
it with an own plugin. Have a look on the docviewer module as an
example.
You must define a file play.plugins and insert
1000:DocViewerPlugin
I would recommend a number > 1000 so that there are enough free
numbers for the plugin himself.
Niels

Jean-Francois Poux

unread,
Sep 21, 2010, 4:57:07 AM9/21/10
to play-framework
Hi,

To have your plugin discovered by play, you have to add a play.plugins
file. Put it somewhere in your classpath, like the conf folder of your
application. There's one built-in the framework under framework/src/
play.plugins. The syntax of this file is priority:pluginClassName.

If you need to route things, you can declare them in the usual route
file, or use something like this in your plugin:
public void onRoutesLoaded() {
Router.addRoute("GET", "/user/{name}", "Users.read");
}


Regards,
Jean-François
> > > > > play-framewor...@googlegroups.com<play-framework%2Bunsubscribe@go oglegroups.com>

DaveM

unread,
Sep 21, 2010, 5:11:54 AM9/21/10
to play-framework
Thanks, so are the steps:

a) extend PlayPlugin

b) create .plugins file in the classpath

Do I create a new app, or module, or is there a plugin skeleton?

Dave

DaveM

unread,
Sep 21, 2010, 5:18:22 AM9/21/10
to play-framework
I think I understand it, looking at doc viewer,
a) it looks like a regular module, under the modules directory
b) it has a class which extends PlayPlugin, in the root namespace,
under apps
c) it has a .plugin file.
cool

D

GrailsDeveloper

unread,
Sep 21, 2010, 5:34:50 AM9/21/10
to play-framework
PlayPlugins can live in a normal app or in a module. As far as I know
this doesn't matter.

Niels

Jean-Francois Poux

unread,
Sep 21, 2010, 5:35:59 AM9/21/10
to play-framework
Hi,

You can try
play new-module moduleName

an play will create en empty module skeleton for you. Whether you want
to do it in your app or in a module depends of what you want to do. If
you want to re-use or publish your code, go for a module, otherwise
it'll fit in your application.

Regards,

DaveM

unread,
Sep 21, 2010, 6:05:10 AM9/21/10
to play-framework
I'm up for publishing my modules.

-One would be an ojectdb module (though could be extended for any jdo
database I guess, Datanucleus for example).

-The other handles comet.

But before that, I need to release some code to customers....

Dave

DaveM

unread,
Sep 21, 2010, 6:16:37 AM9/21/10
to play-framework
wow, it actually worked.

To create a plugin, all I did was:

a) created a class which extends PlayPlugin

b) created a file "play.plugins" with the one-liner with a priority
level, and the name of the plugin class

thanks!

Now, I'm instrumenting all the plugin methods to print their names
when called - I figure that's a good way to understand exactly when
the methods are called.

Dave
Reply all
Reply to author
Forward
0 new messages