I have a transaction manager which i configured like this
<txnmgr name="txnmgr" logger="Q2" class="org.jpos.transaction.TransactionManager">
<property name="space" value="tspace:mySpace"/>
<property name="queue" value="TransactionQueue"/>
<property name="max-sessions" value="10"/>
<participant class="main.java.com.transaction.manager.Switch" logger="Q2">
<property name="0800" value="NetworkManagement" />
<property name="0200" value="FinancialTransaction" />
</participant>
<participant class="main.java.com.transaction.manager.FinancialTransactionResponse" logger="Q2"/>
<group name="NetworkManagement">
<participant class="main.java.com.transaction.manager.NetworkManagementResponse" logger="Q2" />
</group>
<group name="FinancialTransaction">
<participant class="main.java.com.transaction.manager.FinancialTransactionValidateMessage" logger="Q2" />
<participant class="main.java.com.transaction.manager.FinancialTransactionQueryRemoteHost1" logger="Q2" />
<participant class="main.java.com.transaction.manager.FinancialTransactionQueryRemoteHost2" logger="Q2" />
</group>
</txnmgr>
in my FinancialTransactionQueryRemoteHost1 i have
@Override
public int prepare(long l, Serializable srlzbl) {
try{
channelManager = ((ChannelManager) NameRegistrar.get("jpos-host1-adaptor"));
ISOMsg reqMsg = (ISOMsg) ((Context) srlzbl).get(Constants.REQUEST_KEY);
ISOMsg respMsg = channelManager.sendMsg(reqMsg);
((Context) srlzbl).put(Constants.RESPONSE_KEY, respMsg);
return PREPARED;
}catch(NameRegistrar.NotFoundException e){
e.printStackTrace();
return ABORTED;
}catch(Throwable t){
t.printStackTrace();
return ABORTED;
}
}
in my FinancialTransactionQueryRemoteHost2 i have
@Override
public int prepare(long l, Serializable srlzbl) {
try{
channelManager = ((ChannelManager) NameRegistrar.get("jpos-host2-adaptor"));
ISOMsg reqMsg = (ISOMsg) ((Context) srlzbl).get(Constants.REQUEST_KEY);
ISOMsg respMsg = channelManager.sendMsg(reqMsg);
((Context) srlzbl).put(Constants.RESPONSE_KEY, respMsg);
return PREPARED;
}catch(NameRegistrar.NotFoundException e){
e.printStackTrace();
return ABORTED;
}catch(Throwable t){
t.printStackTrace();
return ABORTED;
}
}
in my Financialtransactionresponse i have
@Override
public int prepare(long id, Serializable context) {
Context ctx = (Context)context;
ISOMsg respMsg = (ISOMsg)ctx.get(Constants.RESPONSE_KEY);
//Get IsoMsg from host1
//Get IsoMsg from host2
//compare field 39 response if both are 00
String bit39 = respMsg.getString(70);
if(bit39==null){
respMsg.set(39,"06");
}
ctx.put(Constants.RESPONSE_KEY,respMsg);
return PREPARED;
}
in my transactionresponse how do i get the response of the 2 participant so i can compare before responding i.e comment above on how i would like it to be achieved
You only need to put the responses under two different keys. Let's say response1 and response2:
In
FinancialTransactionQueryRemoteHost1.prepare
:In
FinancialTransactionQueryRemoteHost2.prepare
:Then in
Financialtransactionresponse.prepare
You can use whatever strings you want and define contants for them. You can reuse de
CONTEXT_KEY
for the first and another key for the second.Also and perhaps better yet, you can merge the replies in your
FinancialTransactionQueryRemoteHost2
participant.FYI participants are ran sequentially.
And even more you could reuse the standard QueryHost participant see this tutorial
Thanks to Murtuza Chhil response to ISOMsg parallel request to multiple MUX jpos thread you can also use the join participant as described in Parallel Processing to make the two queries in parallel.