AbortParticipant related question

28 views
Skip to first unread message

Nik

unread,
Jun 9, 2017, 5:26:07 AM6/9/17
to jPOS Users
My SendResponse Participant implements AbortParticipant interface.

Is this correct ?

   
public void abort(long l, Serializable serializable) {
 sendMessage
((Context) serializable);
 
}


private void sendMessage(Context context) {
 
ISOSource source = (ISOSource) context.get(Constants.SOURCE);
 
ISOMsg msgResp = (ISOMsg) context.get(Constants.RESPONSE);
 
try {
 source
.send(msgResp);
 
} catch (IOException e) {
 e
.printStackTrace();
 
} catch (ISOException e) {
 e
.printStackTrace();
 
}
 
}


@Override
public int prepareForAbort(long id, Serializable context) {
 sendMessage
((Context) serializable);
 
return 0;
 
}

If SendResponse Participant joined Transaction and some other Participant returned ABORT later in the assembly line, then abort method of SendResponse will be called.
If SendResponse did not join Transaction and some other Participant returned ABORT, then prepareForAbort method of SendResponse will be called. 

In both the cases, sendMessage will be called and RESPONSE will be sent back to client. 

Alejandro Revilla

unread,
Jun 9, 2017, 1:04:23 PM6/9/17
to jPOS Users
SendResponse implements AbortParticipant because you typically want it to take the opportunity to join the transaction in order to provide a response back to the POS at commit time or abort time. You can of course use a flag in the Context to inhibit the response if you want to just ignore it and have the POS retry the transaction.

Without implementing AbortParticipant, SendResponse would only be able to provide replies in situations where the transactions commits (all participants return PREPARED).



Reply all
Reply to author
Forward
0 new messages