<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Yes, with: @Observes(during = TransactionPhase.AFTER_SUCCESS)<br>
<br>
The relevant methods in the booking example (with my added logging)
are:<br>
@End<br>
@TransactionAttribute(TransactionAttributeType.REQUIRED)<br>
public void confirm() {<br>
LOG.info("confirm begin");<br>
em.persist(booking);<br>
bookingConfirmedEventSrc.fire(booking);<br>
LOG.info("confirm end");<br>
}<br>
<br>
public void onBookingComplete(@Observes(during =
TransactionPhase.AFTER_SUCCESS) @Confirmed final Booking booking) {<br>
LOG.info("onBookingComplete begin");<br>
log.bookingConfirmed(booking.getHotel().getName(),
booking.getUser().getName());<br>
messages.info(new
DefaultBundleKey("booking_confirmed")).defaults("You're booked to
stay at the {0} {1}.")<br>
.params(booking.getHotel().getName(), new
PrettyTime(locale).format(booking.getCheckinDate()));<br>
LOG.info("onBookingComplete end");<br>
}<br>
<br>
Cheers,<br>
Dave.<br>
<br>
On 05/01/12 17:32, Jason Porter wrote:
<blockquote
cite="mid:CAF9TksO_iUDLyXzJPv0ufD4QtQrD5VkTBhozNG55R3xELO=k3w@mail.gmail.com"
type="cite">These are events you're observing?<br>
<br>
<div class="gmail_quote">On Wed, Jan 4, 2012 at 23:27, Dave Oxley
<span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dave@daveoxley.co.uk">dave@daveoxley.co.uk</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I've been attempting to add persistence to the seam-cron
module for<br>
which I need to use transaction events. Unfortunately I cannot
get them<br>
to work. They always get called immediately rather than when
the<br>
transaction is completed. So I turned to the seam-booking
example<br>
(<a moz-do-not-send="true"
href="https://github.com/seam/examples/tree/master/booking"
target="_blank">https://github.com/seam/examples/tree/master/booking</a>)
which I saw was<br>
using transaction events and added some logging (attached),
but this<br>
appears to have the same issue. The output from the log is:<br>
<br>
17:13:16,580 INFO<br>
[org.jboss.seam.examples.booking.booking.BookingAgent]<br>
(http--127.0.0.1-8080-1) confirm begin<br>
17:13:16,587 INFO<br>
[org.jboss.seam.examples.booking.booking.BookingHistory]<br>
(http--127.0.0.1-8080-1) Adding new booking to user's cached
booking history<br>
17:13:16,588 INFO<br>
[org.jboss.seam.examples.booking.booking.BookingAgent]<br>
(http--127.0.0.1-8080-1) onBookingComplete begin<br>
17:13:16,589 INFO<br>
[org.jboss.seam.examples.booking.booking.BookingAgent]<br>
(http--127.0.0.1-8080-1) New booking at the W New York - Union
Square<br>
confirmed for Shane Bryzak.<br>
17:13:16,599 INFO<br>
[org.jboss.seam.examples.booking.booking.BookingAgent]<br>
(http--127.0.0.1-8080-1) onBookingComplete end<br>
17:13:16,600 INFO<br>
[org.jboss.seam.examples.booking.booking.BookingAgent]<br>
(http--127.0.0.1-8080-1) confirm end<br>
<br>
But in theory the order of the logging should be:<br>
confirm begin<br>
confirm end<br>
onBookingComplete begin<br>
onBookingComplete end<br>
<br>
I did note that there was nothing specifying a transaction was
required<br>
for the entirety of the confirm method so I also added<br>
@TransactionAttribute(TransactionAttributeType.REQUIRED) to
the method<br>
(also in attached patch), but that had the same result.<br>
<br>
I've been trying this in jboss-as-web-7.0.2.Final. I'm
probably doing<br>
something wrong but I don't know what. Does anyone have any
ideas?<br>
<br>
Cheers,<br>
Dave.<br>
<br>
_______________________________________________<br>
seam-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/seam-dev"
target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
Jason Porter<br>
<a moz-do-not-send="true" href="http://lightguard-jp.blogspot.com"
target="_blank">http://lightguard-jp.blogspot.com</a><br>
<a moz-do-not-send="true" href="http://twitter.com/lightguardjp"
target="_blank">http://twitter.com/lightguardjp</a><br>
<br>
Software Engineer<br>
Open Source Advocate<br>
Author of Seam Catch - Next Generation Java Exception Handling<br>
<br>
PGP key id: 926CCFF5<br>
PGP key available at: <a moz-do-not-send="true"
href="http://keyserver.net" target="_blank">keyserver.net</a>, <a
moz-do-not-send="true" href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>
</blockquote>
<br>
</body>
</html>