Search in sources :

Example 71 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class MultiParticipantCoordinatorCompletionParticipantCloseTest method run.

public void run() {
    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
    // ignore
    }
    String serviceURL1;
    String subserviceURL1;
    serviceURL1 = System.getProperty(XTSServiceTest.SERVICE_URL1_KEY);
    if (serviceURL1 == null) {
        serviceURL1 = "http://localhost:8080/xtstest/xtsservicetest1";
    }
    subserviceURL1 = System.getProperty(XTSServiceTest.SUBORDINATE_SERVICE_URL1_KEY);
    if (subserviceURL1 == null) {
        subserviceURL1 = "http://localhost:8080/xtstest/xtssubordinateservicetest1";
    }
    addDefaultBinding("service1", serviceURL1);
    addDefaultBinding("subservice1", subserviceURL1);
    UserBusinessActivity ba = UserBusinessActivityFactory.userBusinessActivity();
    try {
        ba.begin();
    } catch (WrongStateException e) {
        exception = e;
    } catch (SystemException e) {
        exception = e;
    }
    if (exception != null) {
        error("txbegin failure " + exception);
        return;
    }
    List<String> resultsList;
    String participantId;
    List<String> commands = new ArrayList<String>();
    List<String> results = new ArrayList<String>();
    commands.add("block");
    commands.add("serve");
    commands.add("{service1}");
    commands.add("enlistCoordinatorCompletion");
    commands.add("complete");
    commands.add("close");
    commands.add("bindings");
    commands.add("bind");
    commands.add("P1");
    commands.add("0");
    commands.add("next");
    commands.add("serve");
    commands.add("{subservice1}");
    commands.add("enlistCoordinatorCompletion");
    commands.add("complete");
    commands.add("close");
    commands.add("next");
    commands.add("serve");
    commands.add("{subservice1}");
    commands.add("enlistCoordinatorCompletion");
    commands.add("complete");
    commands.add("close");
    commands.add("endblock");
    try {
        processCommands(commands, results);
    } catch (Exception e) {
        exception = e;
    }
    if (exception != null) {
        error("test failure " + exception);
        return;
    }
    try {
        ba.close();
    } catch (TransactionRolledBackException e) {
        exception = e;
    } catch (UnknownTransactionException e) {
        exception = e;
    } catch (SystemException e) {
        exception = e;
    } catch (WrongStateException e) {
        exception = e;
    }
    if (exception != null) {
        error("commit failure " + exception);
    }
    message("completed");
    isSuccessful = (exception == null);
}
Also used : SystemException(com.arjuna.wst.SystemException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) WrongStateException(com.arjuna.wst.WrongStateException) ArrayList(java.util.ArrayList) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) WrongStateException(com.arjuna.wst.WrongStateException) SystemException(com.arjuna.wst.SystemException)

Example 72 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class WSBAHandler method notifyFailure.

@Override
public void notifyFailure() throws TXFrameworkException {
    try {
        participantManager.cannotComplete();
    } catch (WrongStateException e) {
        throw new TXFrameworkException("Error notifying cannotComplete on participant manager.", e);
    } catch (UnknownTransactionException e) {
        throw new TXFrameworkException("Error notifying cannotComplete on participant manager.", e);
    } catch (SystemException e) {
        throw new TXFrameworkException("Error notifying cannotComplete on participant manager.", e);
    }
    Participant.suspend();
    WSBATxControlImpl.suspend();
}
Also used : TXFrameworkException(org.jboss.narayana.txframework.api.exception.TXFrameworkException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) WrongStateException(com.arjuna.wst.WrongStateException)

Example 73 with SystemException

use of com.arjuna.wst.SystemException in project narayana by jbosstm.

the class WSBAHandler method notifySuccess.

@Override
public void notifySuccess() throws TXFrameworkException {
    // todo: find a better way of getting the current status of the TX
    if (shouldComplete(serviceInvocationMeta.getServiceMethod()) && !((WSBATxControlImpl) wsbaTxControl).isCannotComplete()) {
        try {
            participantManager.completed();
        } catch (WrongStateException e) {
            throw new TXFrameworkException("Error notifying completion on participant manager.", e);
        } catch (UnknownTransactionException e) {
            throw new TXFrameworkException("Error notifying completion on participant manager.", e);
        } catch (SystemException e) {
            throw new TXFrameworkException("Error notifying completion on participant manager.", e);
        }
    }
    Participant.suspend();
    WSBATxControlImpl.suspend();
}
Also used : TXFrameworkException(org.jboss.narayana.txframework.api.exception.TXFrameworkException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) WrongStateException(com.arjuna.wst.WrongStateException)

Example 74 with SystemException

use of com.arjuna.wst.SystemException in project wildfly by wildfly.

the class BACoordinatorCompletionSuperService method saveData.

/**
 * Add an item to a set and enroll a Participant if necessary then pass the call through to the business logic.
 *
 * @param value the value to add to the set.
 * @throws AlreadyInSetException if value is already in the set
 * @throws SetServiceException   if an error occurred when attempting to add the item to the set.
 */
public void saveData(String value, ServiceCommand... serviceCommands) throws TestApplicationException {
    log.trace("[BA COORDINATOR COMPL SERVICE] web method saveData('" + value + "')");
    eventLog.foundEventLogName(value);
    BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
    // transaction context associated with this thread
    String transactionId;
    try {
        transactionId = activityManager.currentTransaction().toString();
    } catch (SystemException e) {
        throw new RuntimeException("Unable to lookup existing business activity", e);
    }
    // Lookup existing participant or register new participant (
    BACoordinationCompletionParticipant participantBA = BACoordinationCompletionParticipant.getSomeParticipant(transactionId);
    if (participantBA != null && ServiceCommand.isPresent(REUSE_BA_PARTICIPANT, serviceCommands)) {
        log.trace("[BA COORDINATOR COMPL SERVICE] Re-using the existing participant, already registered for this BA - command set to: " + REUSE_BA_PARTICIPANT);
    } else {
        try {
            // enlist the Participant for this service:
            participantBA = new BACoordinationCompletionParticipant(serviceCommands, eventLog, transactionId, value);
            BACoordinationCompletionParticipant.recordParticipant(transactionId, participantBA);
            log.trace("[BA COORDINATOR COMPL SERVICE] Enlisting a participant into the BA");
            BAParticipantManager baParticipantManager = activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participantBA, "BACoordinatorCompletition:" + new Uid().toString());
            if (ServiceCommand.isPresent(CANNOT_COMPLETE, serviceCommands)) {
                baParticipantManager.cannotComplete();
                return;
            }
            if (ServiceCommand.isPresent(DO_COMPLETE, serviceCommands)) {
                throw new RuntimeException("Only ParticipantCompletion participants are supposed to call complete. " + "CoordinatorCompletion participants need to wait to be notified by the coordinator.");
            }
        } catch (Exception e) {
            log.error("[BA COORDINATOR COMPL SERVICE] Participant enlistment failed", e);
            throw new RuntimeException("Error enlisting participant", e);
        }
    }
    if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
        throw new TestApplicationException("Intentionally thrown Application Exception - service command set to: " + APPLICATION_EXCEPTION);
    }
    // invoke the back-end business logic
    log.trace("[BA COORDINATOR COMPL SERVICE] Invoking the back-end business logic - saving value: " + value);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) TestApplicationException(org.jboss.as.test.xts.base.TestApplicationException) SystemException(com.arjuna.wst.SystemException) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) BAParticipantManager(com.arjuna.wst11.BAParticipantManager) TestApplicationException(org.jboss.as.test.xts.base.TestApplicationException) SystemException(com.arjuna.wst.SystemException)

Aggregations

SystemException (com.arjuna.wst.SystemException)74 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)63 WrongStateException (com.arjuna.wst.WrongStateException)45 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)39 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)20 ArrayList (java.util.ArrayList)19 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)16 UserBusinessActivity (com.arjuna.mw.wst11.UserBusinessActivity)15 SoapFault (com.arjuna.webservices.SoapFault)15 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)13 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)11 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)11 MAP (org.jboss.ws.api.addressing.MAP)11 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)10 Context (com.arjuna.mw.wsc11.context.Context)6 FaultedException (com.arjuna.wst.FaultedException)6 BusinessActivityTerminator (com.arjuna.wst11.BusinessActivityTerminator)6 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)6 TxContext (com.arjuna.mw.wst.TxContext)5 BusinessActivityManager (com.arjuna.mw.wst11.BusinessActivityManager)5