use of com.arjuna.webservices11.wsarj.InstanceIdentifier in project narayana by jbosstm.
the class CompletionParticipantTest method testSendRollback.
@Test
public void testSendRollback() throws Exception {
final String messageId = "testSendRollback";
final MAP map = AddressingHelper.createRequestContext(TestUtil.completionCoordinatorServiceURI, messageId);
final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("2");
final W3CEndpointReference endpoint = TestUtil.getCompletionCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier());
CompletionCoordinatorClient.getClient().sendRollback(endpoint, map, new InstanceIdentifier("sender"));
final CompletionCoordinatorDetails details = testCompletionCoordinatorProcessor.getCompletionCoordinatorDetails(messageId, 10000);
assertTrue(details.hasRollback());
checkDetails(details, true, true, messageId, instanceIdentifier);
}
use of com.arjuna.webservices11.wsarj.InstanceIdentifier in project narayana by jbosstm.
the class CompletionParticipantTest method checkDetails.
private void checkDetails(CompletionCoordinatorDetails details, boolean hasFrom, boolean hasFaultTo, String messageId, InstanceIdentifier instanceIdentifier) {
MAP inMAP = details.getMAP();
ArjunaContext inArjunaContext = details.getArjunaContext();
assertEquals(inMAP.getTo(), TestUtil.completionCoordinatorServiceURI);
assertNotNull(inMAP.getReplyTo());
assertTrue(AddressingHelper.isNoneReplyTo(inMAP));
if (hasFrom) {
assertNotNull(inMAP.getFrom());
assertEquals(inMAP.getFrom().getAddress(), TestUtil.completionInitiatorServiceURI);
} else {
assertNull(inMAP.getFrom());
}
if (hasFaultTo) {
assertNotNull(inMAP.getFaultTo());
assertEquals(inMAP.getFaultTo().getAddress(), TestUtil.completionInitiatorServiceURI);
} else {
assertNull(inMAP.getFrom());
}
assertNotNull(inMAP.getMessageID());
assertEquals(inMAP.getMessageID(), messageId);
if (instanceIdentifier == null) {
assertNull(inArjunaContext);
} else {
assertNotNull(inArjunaContext);
assertEquals(instanceIdentifier.getInstanceIdentifier(), inArjunaContext.getInstanceIdentifier().getInstanceIdentifier());
}
}
use of com.arjuna.webservices11.wsarj.InstanceIdentifier in project narayana by jbosstm.
the class TwoPCParticipantTest method checkDetails.
/**
* check the message details to see that they have the correct to, from and faultto address and message id, a
* none reply to address and an arjuna context containing the correct instannce identifier
* @param details
* @param hasFrom
* @param hasFaultTo
* @param messageId
* @param instanceIdentifier
*/
private void checkDetails(CoordinatorDetails details, boolean hasFrom, boolean hasFaultTo, String messageId, InstanceIdentifier instanceIdentifier) {
MAP inMAP = details.getMAP();
ArjunaContext inArjunaContext = details.getArjunaContext();
assertEquals(inMAP.getTo(), TestUtil.coordinatorServiceURI);
assertNotNull(inMAP.getReplyTo());
assertTrue(AddressingHelper.isNoneReplyTo(inMAP));
if (hasFrom) {
assertNotNull(inMAP.getFrom());
assertEquals(inMAP.getFrom().getAddress(), TestUtil.participantServiceURI);
} else {
assertNull(inMAP.getFrom());
}
if (hasFaultTo) {
assertNotNull(inMAP.getFaultTo());
assertEquals(inMAP.getFaultTo().getAddress(), TestUtil.participantServiceURI);
} else {
assertNull(inMAP.getFrom());
}
assertNotNull(inMAP.getMessageID());
assertEquals(inMAP.getMessageID(), messageId);
if (instanceIdentifier == null) {
assertNull(inArjunaContext);
} else {
assertNotNull(inArjunaContext);
assertEquals(instanceIdentifier.getInstanceIdentifier(), inArjunaContext.getInstanceIdentifier().getInstanceIdentifier());
}
}
use of com.arjuna.webservices11.wsarj.InstanceIdentifier in project narayana by jbosstm.
the class InstanceIdentifierHandler method handlemessageInbound.
/**
* check for an arjuna instance identifier element embedded in the soap message headesr and, if found, use it to
* label an arjuna context attached to the message context
* @param context
* @return
* @throws ProtocolException
*/
private boolean handlemessageInbound(SOAPMessageContext context) throws ProtocolException {
try {
final SOAPMessage soapMessage = context.getMessage();
final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
Iterator<SOAPHeaderElement> iterator = soapEnvelope.getHeader().examineAllHeaderElements();
while (iterator.hasNext()) {
final SOAPHeaderElement headerElement = iterator.next();
if (ArjunaConstants.WSARJ_ELEMENT_INSTANCE_IDENTIFIER_QNAME.equals(headerElement.getElementQName())) {
// found it - clear the must understand flag, retrieve the value and store an arjuna
// context in the message context
headerElement.setMustUnderstand(false);
String identifierString = headerElement.getValue();
if (identifierString != null) {
ArjunaContext arjunaContext = ArjunaContext.getContext(context);
arjunaContext.setInstanceIdentifier(new InstanceIdentifier(identifierString));
break;
}
}
}
} catch (Exception se) {
throw new ProtocolException(se);
}
return true;
}
use of com.arjuna.webservices11.wsarj.InstanceIdentifier in project narayana by jbosstm.
the class CompletionCoordinatorProcessorImpl method commit.
/**
* Commit.
* @param commit The commit notification.
* @param map The addressing context.
* @param arjunaContext The arjuna context.
*/
public void commit(final Notification commit, final MAP map, final ArjunaContext arjunaContext) {
final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
final CompletionCoordinatorParticipant participant = getParticipant(instanceIdentifier);
try {
if (participant != null) {
final String messageId = MessageId.getMessageId();
try {
participant.commit();
} catch (final TransactionRolledBackException trbe) {
final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
CompletionInitiatorClient.getClient().sendAborted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
return;
} catch (final UnknownTransactionException ute) {
final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_1());
CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
return;
} catch (final SystemException se) {
final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
final String pattern = WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_2();
final String message = MessageFormat.format(pattern, new Object[] { se });
final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
return;
} catch (final Throwable th) {
if (WSTLogger.logger.isTraceEnabled()) {
WSTLogger.logger.tracev("Unexpected exception thrown from commit:", th);
}
final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
final SoapFault soapFault = new SoapFault11(th);
CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
return;
}
final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
CompletionInitiatorClient.getClient().sendCommitted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
} else {
if (WSTLogger.logger.isTraceEnabled()) {
WSTLogger.logger.tracev("Commit called on unknown participant: {0}", new Object[] { instanceIdentifier });
}
final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_5());
CompletionInitiatorClient.getClient().sendSoapFault(faultAddressingContext, soapFault, instanceIdentifier);
}
} catch (Throwable throwable) {
throwable.printStackTrace(System.err);
}
}
Aggregations