Package com.arjuna.mw.wst11

Examples of com.arjuna.mw.wst11.TransactionManager


public class MultiCancel extends TestCase
{
    public static void testMultiCancel()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CANCEL, "1239");
      FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CANCEL, "5678");
      try {
      uba.begin();

      bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1239");
      bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5678");
        } catch (Exception eouter) {
            try {
                uba.cancel();
            } catch(Exception einner) {
            }
            throw eouter;
        }
      try {
      uba.cancel();
        } catch (SystemException ex) {
            // failure will result in heuristic hazard warning message but wil not throw an exception
            throw ex;
        } catch (Exception eouter) {
            try {
                uba.cancel();
            } catch(Exception einner) {
            }
            throw eouter;
        }
        assertTrue(p.passed());
View Full Code Here


        PrintWriter out = resp.getWriter();

        out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *JBoss WildFly*.</h1>");

        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            out.write("<p><i>Go to your WildFly console or Server log to see the result of the transaction</i></p>");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

    public void testCommit() throws Exception {

        System.out
                .println("\n\nStarting 'testCommit'. This test invokes a WS within an AT. The AT is later committed, which causes the back-end resource(s) to be committed.");
        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals(1, client.getBookingCount());

        } finally {
View Full Code Here

    public void testRollback() throws Exception {

        System.out
                .println("\n\nStarting 'testRollback'. This test invokes a WS within an AT. The AT is later rolled back, which causes the back-end resource(s) to be rolled back.");
        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out
                    .println("[CLIENT] rolling back Atomic Transaction (This will cause the AT and thus the enlisted back-end resources to rollback)");
            ut.rollback();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals(0, client.getBookingCount());

        } finally {
View Full Code Here

     * @throws Exception if something goes wrong.
     */
    @Test
    public void testCommit() throws Exception {
        log.info("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            log.info("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            log.info("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            log.info("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals("Commit on the Durable2PC participant has not been invoked.", 1, client.getBookingCount());
            Assert.assertTrue("Commit on the Volatile2PC participant has not been invoked.", client.wasVolatileCommit());
            Assert.assertFalse("Rollback on the Volatile2PC participant has been invoked.", client.wasVolatileRollback());
View Full Code Here

     * @throws Exception if something goes wrong
     */
    @Test
    public void testRollback() throws Exception {
        log.info("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            log.info("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            log.info("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            log.info("[CLIENT] rolling back Atomic Transaction (This will cause the AT and thus the enlisted back-end resources to rollback)");
            ut.rollback();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals("Rollback on the Durable2PC participant has not been invoked.", 0, client.getBookingCount());
            Assert.assertFalse("Commit on the Volatile2PC participant has been invoked.", client.wasVolatileCommit());
            Assert.assertTrue("Rollback on the Volatile2PC participant has not been invoked.", client.wasVolatileRollback());
View Full Code Here

    @Test
    public void testActiveTransaction() throws Exception {
        final String deploymentUrl = getDeploymentUrl();
        final TransactionalService transactionalService = TransactionalClient.newInstance(deploymentUrl);
        final UserTransaction userTransaction = UserTransaction.getUserTransaction();

        userTransaction.begin();
        final boolean isTransactionActive = transactionalService.isTransactionActive();
        userTransaction.commit();

        Assert.assertEquals(true, isTransactionActive);
    }
View Full Code Here

     */
    public void invokeWithCallName(String callName, ServiceCommand[] serviceCommands) throws TestApplicationException {
       
        log.infof("[AT SERVICE] web method invoke(%s) with eventLog %s", callName, eventLog);
        eventLog.foundEventLogName(callName);
        UserTransaction userTransaction;
       
        try {
            userTransaction = UserTransactionFactory.userTransaction();
            String transactionId = userTransaction.transactionIdentifier();
            log.debug("RestaurantServiceAT transaction id =" + transactionId);
           
            // Enlist the Durable Participant for this service
            TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
            ATDurableParticipant durableParticipant = new ATDurableParticipant(serviceCommands, callName, eventLog, transactionId);
            log.info("[SERVICE] Enlisting a Durable2PC participant into the AT");
            transactionManager.enlistForDurableTwoPhase(durableParticipant, "ATServiceDurable:" + new Uid().toString());
           
            // Enlist the Volatile Participant for this service
            ATVolatileParticipant volatileParticipant = new ATVolatileParticipant(serviceCommands, callName, eventLog, transactionId);
            log.info("[SERVICE] Enlisting a VolatilePC participant into the AT");
            transactionManager.enlistForVolatileTwoPhase(volatileParticipant, "ATServiceVolatile:" + new Uid().toString());
        } catch (Exception e) {
            throw new RuntimeException("Error when enlisting participants", e);
        }
       
        if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
            throw new TestApplicationException("Intentionally thrown Application Exception - service command was set to: " + APPLICATION_EXCEPTION);
        }
       
        if (ServiceCommand.isPresent(ROLLBACK_ONLY, serviceCommands)) {
            log.info("Intentionally the service settings transaction to rollback only - service command was set to: " + ROLLBACK_ONLY);
            try {
                userTransaction.rollback();
            } catch (Exception e) {
                throw new RuntimeException("The rollback is not possible", e);
            }
        }

View Full Code Here

        PrintWriter out = resp.getWriter();

        out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *Red Hat JBoss Enterprise Application Platform 6*.</h1>");

        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            out.write("<p><b>Transaction succeeded!</b></p>");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

    public void testCommit() throws Exception {

        System.out
                .println("\n\nStarting 'testCommit'. This test invokes a WS within an AT. The AT is later committed, which causes the back-end resource(s) to be committed.");
        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals(1, client.getBookingCount());

        } finally {
View Full Code Here

TOP

Related Classes of com.arjuna.mw.wst11.TransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.