Search in sources :

Example 76 with ArjunaContext

use of com.arjuna.webservices11.wsarj.ArjunaContext in project narayana by jbosstm.

the class CoordinatorEngine method sendUnknownTransaction.

/**
 * Send the UnknownTransaction message.
 */
private void sendUnknownTransaction(final MAP map, final ArjunaContext arjunaContext) {
    try {
        final MAP faultMAP = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
        final String message = WSTLogger.i18NLogger.get_wst11_messaging_engines_CoordinatorEngine_sendUnknownTransaction_1();
        final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, AtomicTransactionConstants.WSAT_ERROR_CODE_UNKNOWN_TRANSACTION_QNAME, message);
        ParticipantClient.getClient().sendSoapFault(faultMAP, soapFault, instanceIdentifier);
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.warn_wst11_messaging_engines_CoordinatorEngine_sendUnknownTransaction_2(id, th);
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) MAP(org.jboss.ws.api.addressing.MAP)

Example 77 with ArjunaContext

use of com.arjuna.webservices11.wsarj.ArjunaContext in project narayana by jbosstm.

the class ParticipantCompletionParticipantEngine method getStatus.

/**
 * Handle the getStatus event.
 * @param getStatus The getStatus notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void getStatus(final NotificationType getStatus, final MAP map, final ArjunaContext arjunaContext) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".getStatus");
    }
    final State current;
    synchronized (this) {
        current = state;
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".getStatus. State: " + current);
    }
    sendStatus(current);
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 78 with ArjunaContext

use of com.arjuna.webservices11.wsarj.ArjunaContext in project narayana by jbosstm.

the class ParticipantCompletionParticipantEngine method failed.

/**
 * Handle the failed event.
 * @param failed The failed notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 *
 * Active -> Active (invalid state)
 * Canceling -> Canceling (invalid state)
 * Completed -> Completed (invalid state)
 * Closing -> Closing (invalid state)
 * Compensating -> Compensating (invalid state)
 * Failing-Active -> Ended
 * Failing-Canceling -> Ended
 * Failing-Compensating -> Ended
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended
 */
public void failed(final NotificationType failed, final MAP map, final ArjunaContext arjunaContext) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".failed");
    }
    final State current;
    boolean deleteRequired = false;
    synchronized (this) {
        current = state;
        if ((current == State.STATE_FAILING_ACTIVE) || (current == State.STATE_FAILING_CANCELING) || (current == State.STATE_FAILING_COMPENSATING)) {
            deleteRequired = persisted;
        }
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".failed. State: " + current);
    }
    if (deleteRequired) {
        if (!XTSBARecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
            // hmm, could not delete entry -- nothing more we can do than log a message
            WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantCompletionParticipantEngine_failed_1(id);
        }
    }
    // now the log record has been deleted we can safely end this participant
    if ((current == State.STATE_FAILING_ACTIVE) || (current == State.STATE_FAILING_CANCELING) || (current == State.STATE_FAILING_COMPENSATING)) {
        ended();
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 79 with ArjunaContext

use of com.arjuna.webservices11.wsarj.ArjunaContext in project narayana by jbosstm.

the class ParticipantCompletionCoordinatorEngine method status.

/**
 * Handle the status event.
 * @param status The status.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void status(final StatusType status, final MAP map, final ArjunaContext arjunaContext) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".status");
    }
    // TODO - is this correct?
    final State current;
    synchronized (this) {
        current = state;
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".status. State: " + current);
    }
    sendStatus(current);
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 80 with ArjunaContext

use of com.arjuna.webservices11.wsarj.ArjunaContext in project narayana by jbosstm.

the class ParticipantCompletionCoordinatorEngine method fail.

/**
 * Handle the fail event.
 * @param fail The fail exception.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 *
 * Active -> Failing-Active
 * Canceling -> Failing-Canceling
 * Completed -> Completed (invalid state)
 * Closing -> Closing (invalid state)
 * Compensating -> Failing-Compensating
 * Failing-Active -> Failing-Active
 * Failing-Canceling -> Failing-Canceling
 * Failing-Compensating -> Failing-Compensating
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended (resend Failed)
 *
 * In fact we only execute the transition to FAILING_ACTIVE and in this case we send a message to the
 * coordinator by calling executeFail. This propagates the failure back thorugh the activityy hierarchy
 * to the relevant participant and also marks the acivity as ABORT_ONLY.
 *
 * In the other failure cases we do not change to a FAILING_XXX state but instead go straight to ENDED
 * and save the failing state in a field failureState. In these cases there will be a coordinator
 * close/cancel/compensate thread waiting on the change to state FAILING_XXX. The change to FAILING_XXX
 * will wake it up and, if the state is still FAILING_XXX, return a fault to the coordinator, However,
 * the failing thread also sends a failed response and then call ended. This means the state might be
 * transitioned to ENDED before the coordinator thread is scheduled. So, we have to avoid this race by
 * going straight to ENDED and saving a failureState which the coordinator thread can check.
 *
 * The failureState also avoids another race condition for these (non-ACTIVE) cases. It means we don't have
 * to send a message to the coordinator to notify the failure. We would need to do this after the state
 * change as we need to exclude threads handling resent messages. However, the waiting coordinator thread
 * is woken by the state change and so it might complete and remove the activity before the message is sent
 * causing a NoSuchActivity exception in this thread. Settign the  failureState ensures that the failure is
 * detected cleanly by any waiting coordinator thread.
 *
 * Fortuitously, this also avoids problems during recovery. During recovery we have no link to our
 * coordinator available since there is no activity hierarchy in the current context. So, communicating
 * failures via the failureState is the only way to ensure that the recovreed coordinator sees a failure.
 * There is a further wrinkle here too. If a recovered coordinator times out waiting for a response we need
 * to leave the engine in place when we ditch the recovered coordinator and then reestablish a link to it
 * next time we recreate the coordinator. We cannot afford to miss a failure during this interval but the]
 * engine must transition to ENDED after handling the failure. Saving the failure state ensures that the
 * next time the coordinator calls cancel, compensate or close it receives a fault indicating a failure
 * rather than just detecting that the pariticpant  has ended.
 */
public void fail(final ExceptionType fail, final MAP map, final ArjunaContext arjunaContext) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".fail");
    }
    final State current;
    synchronized (this) {
        current = state;
        if (current == State.STATE_ACTIVE) {
            changeState(State.STATE_FAILING_ACTIVE);
        } else if (current == State.STATE_CANCELING) {
            failureState = State.STATE_FAILING_CANCELING;
            ended();
        } else if (current == State.STATE_COMPENSATING) {
            failureState = State.STATE_FAILING_COMPENSATING;
            ended();
        }
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".fail. State: " + current);
    }
    if (current == State.STATE_ACTIVE) {
        executeFail(fail.getExceptionIdentifier());
    } else if ((current == State.STATE_CANCELING) || (current == State.STATE_COMPENSATING) || (current == State.STATE_ENDED)) {
        sendFailed();
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

Aggregations

MAP (org.jboss.ws.api.addressing.MAP)95 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)83 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)74 MessageContext (javax.xml.ws.handler.MessageContext)68 Task (com.arjuna.services.framework.task.Task)62 Action (javax.xml.ws.Action)54 NotificationType (org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType)29 SoapFault (com.arjuna.webservices.SoapFault)17 Notification (org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)15 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)13 SoapFault11 (com.arjuna.webservices11.SoapFault11)12 NotificationType (com.arjuna.schemas.ws._2005._10.wsarjtx.NotificationType)10 CoordinatorCompletionCoordinatorInboundEvents (com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents)10 CoordinatorCompletionParticipantInboundEvents (com.arjuna.webservices11.wsba.CoordinatorCompletionParticipantInboundEvents)10 ParticipantCompletionCoordinatorInboundEvents (com.arjuna.webservices11.wsba.ParticipantCompletionCoordinatorInboundEvents)10 ParticipantCompletionParticipantInboundEvents (com.arjuna.webservices11.wsba.ParticipantCompletionParticipantInboundEvents)9 State (com.arjuna.webservices11.wsba.State)9 ProtocolException (javax.xml.ws.ProtocolException)9 SystemException (com.arjuna.wst.SystemException)8 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)8