Duplicate message

175 views
Skip to first unread message

Stjepan Buljat

unread,
Sep 10, 2015, 10:13:30 AM9/10/15
to jPOS Users
I'm experiencing a strange behavior using jPOS but I'm not sure if this is related to jPOS or not.

Scenario
I'm sending a message to connected client via qmux and expect a response within a given timeout. 
What happens next is strange. The same message I sent gets received on my listener and processed and then I get a response from qmux.
You can find the log attached to this post.


Any ideas? I'm pretty confident this redundant message doesn't come from client application because if something bad happens while processing this message (incoming copied) then I don't get a response on qmux.

Thanks!

Best,
Stjepan


-------------

Here're interesting snippets of code:

QMUX config

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="m-jpos-mux">
  <key>11</key>
  <in>CQ</in>
  <out>MQ</out>
  <unhandled>UNHANDLED</unhandled>
</mux>

ISOSERVER config

<qserver name="m-jpos-server" logger="Q2">
<attr name="port" type="java.lang.Integer">19920</attr>
<channel name="channel.1" logger="Q2"
class="org.jpos.iso.channel.NACChannel"
packager="org.jpos.iso.packager.ISO93BPackager">
<property name="timeout" value="900000" /> <!-- 15 minutes -->
<property name="packager-logger" value="Q2" />
</channel>
<request-listener class="MListener" logger="Q2">
<property name="space" value="tspace:default" />
<property name="queue" value="MTxQueue" />
</request-listener>

<in>MQ</in>
<out>CQ</out>
</qserver>


Send msg via qmux

if(isoServer.getConnections()>0 && qmux.isConnected()) {

ISOMsg response = qmux.request(msg, 5000);

log.info("Received RESPONSE: " + response);
}


Receive msg on main listener

public boolean process (ISOSource source, ISOMsg m) {
try {

if(m.isResponse()==true){
return false;
}else{
Context ctx = new Context ();
ctx.put(REQUEST, m);
ctx.put(ISOSOURCE, source);
ctx.put(TIMER_START, System.currentTimeMillis());
ctx.put(HANDLER_FOUND, false);
ctx.put(MESSAGE_ID, msgLogId);

sp.out (queueName, ctx);

log.info("Process ISOMsg " + m.toString());

return true;
}
} catch (ISOException e) {
log.error("Unable to check if ISOMsg " + m + " is a response. Reason: " + e.getMessage(), e);
return false;
}
}



jpos.log

chhil

unread,
Sep 10, 2015, 10:39:55 AM9/10/15
to jpos-...@googlegroups.com
Just thinking out aloud...

If you return false in your process method, it probably goes to the qservers process method.

You send a request using the servers mux, its going to respond. The response will get handled in your listener. You probably want to return true and just not do anything with the response. If its a request, put it on the context etc and return true.

-chhil

--
--
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
 
Join us in IRC at http://webchat.freenode.net/?channels=jpos
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
---
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/310bdedd-b41f-4464-918a-939b333b056d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Sep 10, 2015, 2:15:30 PM9/10/15
to jpos-...@googlegroups.com

I couldnt reproduce your problem with the following test code (mimics your setup).

Server Mux

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="m-jpos-mux">
  <key>11</key>
  <in>CQ</in>
  <out>MQ</out>
  <unhandled>UNHANDLED</unhandled>
</mux>

Server

<?xml version="1.0" ?>
<server name="test-network-server" class="org.jpos.q2.iso.QServer" logger="Q2">
  <attr name="port" type="java.lang.Integer">19920</attr>
  <channel name="test.channel"
          class="org.jpos.iso.channel.NACChannel"
          packager="org.jpos.iso.packager.ISO93BPackager" logger="Q2">
  </channel>
    <request-listener class="ServerListener" logger="Q2">
        <property name="space" value="tspace:default" />
        <property name="queue" value="MTxQueue" />
    </request-listener>

    <in>MQ</in>
    <out>CQ</out>
</server>

A bean that gets the servers mux and sends the request

<one-shot class="Inject" logger="Q2">

 </one-shot>

ServerListener based on your logic

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISORequestListener;
import org.jpos.iso.ISOSource;

public class ServerListener implements ISORequestListener {

    @Override
    public boolean process (ISOSource source, ISOMsg m) {
        try {

            if(m.isResponse()==true){
                return false;
            }else{

                System.out.println(("Process ISOMsg " + m.toString()));

                return true;
            }
        } catch (ISOException e) {
            System.out.println(("Unable to check if ISOMsg " + m + " is a response. Reason: " + e.getMessage()));
            return false;
        }
    }
}

Standalone client that just responds back/

import java.io.IOException;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOPackager;
import org.jpos.iso.channel.NACChannel;
import org.jpos.iso.packager.ISO93BPackager;

public class ClientChannel {

    public static void main(String[] args) throws IOException, ISOException {

        ISOPackager p = new ISO93BPackager();
        NACChannel ch = new NACChannel("127.0.0.1", 19920, p, null);
        ch.connect();
        ISOMsg m =ch.receive();
        m.setResponseMTI();
        ch.send(m);

    }

}

q2 log

<log realm="Q2.system" at="Thu Sep 10 23:42:46 IST 2015.370">
  <info>
    deploy:C:\Temp\jposlist\build\deploy\10_server_mux.xml
  </info>
</log>
<log realm="Q2.system" at="Thu Sep 10 23:42:46 IST 2015.426">
  <info>
    deploy:C:\Temp\jposlist\build\deploy\20_server.xml
  </info>
</log>
<log realm="Q2.system" at="Thu Sep 10 23:42:46 IST 2015.433">
  <info>
    deploy:C:\Temp\jposlist\build\deploy\30_Injector.xml
  </info>
</log>
<log realm="test-network-server.server" at="Thu Sep 10 23:42:46 IST 2015.475">
  <iso-server>
    listening on port 19920
  </iso-server>
</log>
<log realm="test-network-server.server.session/127.0.0.1:57358" at="Thu Sep 10 23:42:49 IST 2015.904">
  <session-start/>
</log>
<log realm="channel/127.0.0.1:57358" at="Thu Sep 10 23:42:54 IST 2015.891" lifespan="4ms">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.ISO93BPackager -->
      <field id="0" value="0800"/>
      <field id="11" value="123456"/>
    </isomsg>
  </send>
</log>
<log realm="channel/127.0.0.1:57358" at="Thu Sep 10 23:42:54 IST 2015.898" lifespan="4993ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.ISO93BPackager -->
      <field id="0" value="0810"/>
      <field id="11" value="123456"/>
    </isomsg>
  </receive>
</log>
<log realm="channel/127.0.0.1:57358" at="Thu Sep 10 23:42:55 IST 2015.895" lifespan="1ms">
  <receive>
    <peer-disconnect>Connection reset</peer-disconnect>
  </receive>
</log>
<log realm="test-network-server.server.session/127.0.0.1:57358" at="Thu Sep 10 23:42:55 IST 2015.895">
  <session-end/>
</log>

Stjepan Buljat

unread,
Sep 11, 2015, 3:49:20 AM9/11/15
to jPOS Users
Hi chhil,

thanks for you replies.
We also cannot reproduce this on other environments so it must be that our client application for some reason resends received message as is. Will definitely pursue this lead because now it's almost 100% that this is not caused by jPos.

Thanks again.

Best,
Stjepan
Reply all
Reply to author
Forward
0 new messages