Hi Stuart,

Thanks for that. It works correctly for 7.1.CR1b.

Cheers,
Dave.

On 05/01/12 17:47, Stuart Douglas wrote:

Can you try with 7.1.CR1b ? 

There was a bug around this in the 7.0 series that could be causing this.

Stuart

On 05/01/2012, at 5:37 PM, Dave Oxley wrote:

Yes, with: @Observes(during = TransactionPhase.AFTER_SUCCESS)

The relevant methods in the booking example (with my added logging) are:
    @End
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void confirm() {
        LOG.info("confirm begin");
        em.persist(booking);
        bookingConfirmedEventSrc.fire(booking);
        LOG.info("confirm end");
    }

    public void onBookingComplete(@Observes(during = TransactionPhase.AFTER_SUCCESS) @Confirmed final Booking booking) {
        LOG.info("onBookingComplete begin");
        log.bookingConfirmed(booking.getHotel().getName(), booking.getUser().getName());
        messages.info(new DefaultBundleKey("booking_confirmed")).defaults("You're booked to stay at the {0} {1}.")
                .params(booking.getHotel().getName(), new PrettyTime(locale).format(booking.getCheckinDate()));
        LOG.info("onBookingComplete end");
    }

Cheers,
Dave.

On 05/01/12 17:32, Jason Porter wrote:
These are events you're observing?

On Wed, Jan 4, 2012 at 23:27, Dave Oxley <dave@daveoxley.co.uk> wrote:
Hi,

I've been attempting to add persistence to the seam-cron module for
which I need to use transaction events. Unfortunately I cannot get them
to work. They always get called immediately rather than when the
transaction is completed. So I turned to the seam-booking example
(https://github.com/seam/examples/tree/master/booking) which I saw was
using transaction events and added some logging (attached), but this
appears to have the same issue. The output from the log is:

17:13:16,580 INFO
[org.jboss.seam.examples.booking.booking.BookingAgent]
(http--127.0.0.1-8080-1) confirm begin
17:13:16,587 INFO
[org.jboss.seam.examples.booking.booking.BookingHistory]
(http--127.0.0.1-8080-1) Adding new booking to user's cached booking history
17:13:16,588 INFO
[org.jboss.seam.examples.booking.booking.BookingAgent]
(http--127.0.0.1-8080-1) onBookingComplete begin
17:13:16,589 INFO
[org.jboss.seam.examples.booking.booking.BookingAgent]
(http--127.0.0.1-8080-1) New booking at the W New York - Union Square
confirmed for Shane Bryzak.
17:13:16,599 INFO
[org.jboss.seam.examples.booking.booking.BookingAgent]
(http--127.0.0.1-8080-1) onBookingComplete end
17:13:16,600 INFO
[org.jboss.seam.examples.booking.booking.BookingAgent]
(http--127.0.0.1-8080-1) confirm end

But in theory the order of the logging should be:
confirm begin
confirm end
onBookingComplete begin
onBookingComplete end

I did note that there was nothing specifying a transaction was required
for the entirety of the confirm method so I also added
@TransactionAttribute(TransactionAttributeType.REQUIRED) to the method
(also in attached patch), but that had the same result.

I've been trying this in jboss-as-web-7.0.2.Final. I'm probably doing
something wrong but I don't know what. Does anyone have any ideas?

Cheers,
Dave.

_______________________________________________
seam-dev mailing list
seam-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/seam-dev




--
Jason Porter
http://lightguard-jp.blogspot.com
http://twitter.com/lightguardjp

Software Engineer
Open Source Advocate
Author of Seam Catch - Next Generation Java Exception Handling

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu

_______________________________________________
seam-dev mailing list
seam-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/seam-dev