Package org.jboss.as.test.xts.simple.wsba

Examples of org.jboss.as.test.xts.simple.wsba.SetServiceException


            participantManager = activityManager.enlistForBusinessAgreementWithParticipantCompletion(participant,
                    "SetServiceBAImpl:" + new Uid().toString());
        } catch (Exception e) {
            log.error("Participant enlistment failed");
            e.printStackTrace(System.err);
            throw new SetServiceException("Error enlisting participant", e);
        }

        // invoke the back-end business logic
        log.info("[SERVICE] Invoking the back-end business logic");
        MockSetManager.add(value);

        /*
         * this service employs the participant completion protocol which means it decides when it wants to commit local
         * changes. If the local changes (adding the item to the set) succeeded, we notify the coordinator that we have
         * completed. Otherwise, we notify the coordinator that we cannot complete. If any other participant fails or the client
         * decides to cancel we can rely upon being told to compensate.
         */
        log.info("[SERVICE] Prepare the backend resource and if successful notify the coordinator that we have completed our work");
        if (MockSetManager.prepare()) {
            try {
                // tell the coordinator manager we have finished our work
                log.info("[SERVICE] Prepare successful, notifying coordinator of completion");
                participantManager.completed();
            } catch (Exception e) {
                /*
                 * Failed to notify the coordinator that we have finished our work. Compensate the work and throw an Exception
                 * to notify the client that the add operation failed.
                 */
                MockSetManager.rollback(value);

                log.error("[SERVICE]  'completed' callback failed");
                throw new SetServiceException("Error when notifying the coordinator that the work is completed", e);
            }
        } else {
            try {
                /*
                 * tell the participant manager we cannot complete. this will force the activity to fail
                 */
                log.info("[SERVICE] Prepare failed, notifying coordinator that we cannot complete");
                participantManager.cannotComplete();
            } catch (Exception e) {
                log.error("'cannotComplete' callback failed");
                throw new SetServiceException("Error when notifying the coordinator that the work is cannot be completed", e);
            }
            throw new SetServiceException("Unable to prepare the back-end resource");
        }

    }
View Full Code Here


         */
        String transactionId;
        try {
            transactionId = activityManager.currentTransaction().toString();
        } catch (SystemException e) {
            throw new SetServiceException("Unable to lookup existing BusinesActivity", e);
        }

        /*
         * Lookup existing participant or register new participant
         */
        SetParticipantBA participantBA = SetParticipantBA.getParticipant(transactionId);

        if (participantBA == null) {
            try {
                // enlist the Participant for this service:
                SetParticipantBA participant = new SetParticipantBA(transactionId, value);
                SetParticipantBA.recordParticipant(transactionId, participant);

                log.info("[SERVICE] Enlisting a participant into the BA");
                activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participant, "SetServiceBAImpl:"
                        + new Uid().toString());
            } catch (Exception e) {
                log.error("Participant enlistment failed");
                throw new SetServiceException("Error enlisting participant", e);
            }
        } else {
            log.info("[SERVICE] Re-using the existing participant, already registered for this BA");
            participantBA.addValue(value);
        }
View Full Code Here

TOP

Related Classes of org.jboss.as.test.xts.simple.wsba.SetServiceException

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.