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);
}
}
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);
}
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();
}
}
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);
}
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();
}
}
Aggregations