Error Duplicate key

30 views
Skip to first unread message

Sachin Singh

unread,
Nov 8, 2021, 6:35:50 AM11/8/21
to jpos-...@googlegroups.com
Hi  

I am getting an error while sending requests to jpos server.

o.j.t.p.QueryHost.prepare:93 Duplicate key 'jpos-send.020123456.req' detected. error
below are the logs generated by jpos server. Please help me to resolve.
below are the config xmls
20_mux.xmls
	<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="jPOS-AUTORESPONDER">
	<in>jpos-receive</in>
	<out>jpos-send</out>
	<ready>jpos-channel.ready</ready>
	</mux>
10_channel.xmls
<channel-adaptor name="jpos-channel" class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.XMLChannel" packager="org.jpos.iso.packager.XMLPackager">
<property name="host" value="127.0.0.1"/>
<property name="port" value="8000"/>
</channel>
<in>jpos-send</in>
<out>jpos-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>
50_server.xmls
<server class="org.jpos.q2.iso.QServer" logger="Q2" name="xml-server-8000" realm="xml-server-8000">
	<attr name="port" type="java.lang.Integer">8000</attr>
		<channel class="org.jpos.iso.channel.XMLChannel" packager="org.jpos.iso.packager.XMLPackager" type="server" logger="Q2" realm="xml-server-8000">
		<property name="timeout" value="180000"/>
		</channel>
	<request-listener class="org.jpos.iso.IncomingListener" logger="Q2" realm="incoming-request-listener">
		<property name="queue" value="TXNMGR"/>
		<property name="ctx.DESTINATION" value="jPOS-AUTORESPONDER"/>
	</request-listener>
</server>

error:
<log realm="xml-server-8000/127.0.0.1:53556" at="2021-11-08T14:49:17.253" lifespan="3490ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.XMLPackager -->
      <field id="0" value="0200"/>
      <field id="7" value="1108144917"/>
      <field id="11" value="123456"/>
      <field id="70" value="001"/>
    </isomsg>
  </receive>
</log>
<log realm="org.jpos.transaction.TransactionManager" at="2021-11-08T14:49:17.265" lifespan="9ms">
  <abort>
    txnmgr-1:idle:1
    <context>
      TIMESTAMP: Mon Nov 08 14:49:17 IST 2021
      SOURCE: org.jpos.iso.channel.XMLChannel@52d0604b
      REQUEST: 
       <isomsg direction="incoming">
         <!-- org.jpos.iso.packager.XMLPackager -->
         <field id="0" value="0200"/>
         <field id="7" value="1108144917"/>
         <field id="11" value="123456"/>
         <field id="70" value="001"/>
       </isomsg>
      
      DESTINATION: jPOS-AUTORESPONDER
      RESULT: 
       <result>
         <fail>
           [SYSTEM_ERROR] o.j.t.p.QueryHost.prepare:93 Duplicate key 'jpos-send.020123456.req' detected.
         </fail>
       </result>
      
      LOGEVT: 
        <info>
          RESPONSE not present
        </info>
      
    </context>
            prepare: o.j.t.p.QueryHost ABORTED READONLY NO_JOIN
    prepareForAbort: o.j.t.p.SendResponse
              abort: o.j.t.p.SendResponse
     in-transit=0/0, head=2, tail=2, paused=0, outstanding=0, active-sessions=2/128, tps=0, peak=0, avg=0.00, elapsed=9ms
    <profiler>
      prepare: o.j.t.p.QueryHost [8.2/8.2]
      prepareForAbort: o.j.t.p.SendResponse [0.4/8.6]
        abort: o.j.t.p.SendResponse [0.3/8.9]
      end [2.0/10.9]
    </profiler>
  </abort>
</log>
<log realm="stdout" at="2021-11-08T14:49:17.755" lifespan="506ms">
    Req for jpso

</log>
My code is 
public static void main(String[] args) throws Exception {
		Q2 q2= new Q2();
		q2.start();
		Thread.sleep(5*1000);
		QMUX sender=(QMUX) NameRegistrar.get("mux.jPOS-AUTORESPONDER");
		DateFormat formatBit7=new SimpleDateFormat("MMddHHmmss");
		ISOMsg logonRequest=new ISOMsg();
		logonRequest.setMTI("0200");
		logonRequest.set(7,formatBit7.format(new Date()));
		logonRequest.set(11,"123456");
		logonRequest.set(70,"001");
		System.out.println("Req for jpso");
		ISOMsg response=sender.request(logonRequest, 20*1000);
		//new Demo().demoReq() ;
		if(response==null) {
			System.out.println("Response time out");
			return;
		}
		String data = new String(response.pack());
		System.out.println(data);
	}

murtuza chhil

unread,
Nov 8, 2021, 8:33:51 PM11/8/21
to jPOS Users
The mux uses a default of field 11+ field 41 to match requests to responses.
This combination needs to be unique. When the mux sends a request with field 11 =123456 it saves the mti mapping + key in a space until the response comes back, when the response arrives the mux removes the entry and hands the response back to the caller.
If you try and send another request with the same field 11, and the response to the previous one is not received, mux treats it as an error and does not send it. This safeguard prevents duplicate request/advice from being sent.
So, fix your test code to not send the same key (Field 11).

jpos-send.020123456 is telling you that the mti mapping+ key is already being used and hence treats the current one as a duplicate and won't send it out. MTI mapping is just something that enables mapping the 0200 to a 0210 request response.

-chhil

Sachin Singh

unread,
Nov 9, 2021, 6:08:11 AM11/9/21
to jpos-...@googlegroups.com
As you can see it's only for single use.

code is 
public static void main(String[] args) throws Exception {
		Q2 q2= new Q2();
		q2.start();
		Thread.sleep(5*1000);
		QMUX sender=(QMUX) NameRegistrar.get("mux.jPOS-AUTORESPONDER");
		DateFormat formatBit7=new SimpleDateFormat("MMddHHmmss");
		ISOMsg logonRequest=new ISOMsg();
		logonRequest.setMTI("0200");
		logonRequest.set(7,formatBit7.format(new Date()));
		logonRequest.set(11,"123456");
		logonRequest.set(70,"001");
		System.out.println("Req for jpso");
		ISOMsg response=sender.request(logonRequest, 20*1000);
		if(response==null) {
			

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/81b06f67-eeee-487e-a01f-b65cb7e9ddf8n%40googlegroups.com.

murtuza chhil

unread,
Nov 9, 2021, 10:15:00 PM11/9/21
to jPOS Users
The error indicates the mux space already has the key that is being used. Maybe your application is not shutting down completely giving you the impression its being run once.
Where is your q2.stop() ?

-chhil

Reply all
Reply to author
Forward
0 new messages