ISOServer return loss

99 views
Skip to first unread message

Felipe Senefonte

unread,
Oct 27, 2014, 6:15:03 PM10/27/14
to jpos-...@googlegroups.com

Hi, I'm starting to develop a jPOS Server to receive/send ISO via ASCIIChannel.

I'm doing some stress tests with my ISOClient and have 2 situations:

1. When the method  "asciiChannel.receive()" is called 40 times inside a for() loop I got all 40 responses. Works!
2. When I try to call "asciiChannel.receive()" using a Runnable class inside the for loop, to test simultaneous access , I got a lot of losses (something like 15 or 20).
My q2.log returns a lot of ABORTED messages.

In my client side, i got this exception: "IOE: java.io.EOFException"

Can u guys help me with this test? Am I doing something wrong with the client or server?

ClientRunnable.java
    @Override
    public void run() {
        try {
            ASCIIChannel asciiChannel = new ASCIIChannel();
            asciiChannel.setHost("localhost");
            asciiChannel.setPort(11111);
            asciiChannel.setPackager(packager);
            asciiChannel.connect();
            asciiChannel.send(isoMsg);
            asciiChannel.getLogger();
            ISOMsg isoResposta = asciiChannel.receive(); //the error occurs here
            asciiChannel.disconnect();

            System.out.println(logISOMsg(isoResposta, transactionMap.get(isoMsg.getMTI()), true));
        } catch (IOException e) {
            System.out.println("IOE: " + e); //error here
        } catch (ISOException e) {
            System.out.println("ISOE: " + e);
        }
    }

Client.java
public void getMultiResponse(){
        ExecutorService executor = Executors.newFixedThreadPool(20);

        for (int i = 0; i < 20; i++) {
            ClientRunnable worker = new ClientRunnable(isoMsg);
            executor.execute(worker);
        }
        executor.shutdown();
        // Wait until all threads are finish
        while (!executor.isTerminated()) {

        }

        System.out.println("\nFinished all threads");
    }



isoserver.xml
<?xml version="1.0" encoding="UTF-8"?>

<server class="org.jpos.q2.iso.QServer" logger="Q2" name="iso-server">
    <attr name="port" type="java.lang.Integer">11111</attr>
    <property name="space" value="tspace:default" />
    <property name="queue" value="ROL.TXN" />
    <property name="debug" value="true" />

    <channel class="org.jpos.iso.channel.ASCIIChannel" logger="Q2"
             packager="org.jpos.iso.packager.ISO87APackager" realm="ascii-channel">
        <property name="packager-config" value="cfg/packager/iso87ascii.xml" />
        <property name="debug" value="true" />
        <property name="timeout" value="60000" />
        <in>from-default</in>
        <out>to-default</out>
    </channel>

    <request-listener name="isolistener" class="isogateway.listener.RequestListener" logger="Q2"  realm="request-listener">
        <property name="space"   value="tspace:default" />
        <property name="queue"   value="ROL.TXN" />
        <property name="debug" value="true" />
    </request-listener>

</server>

and the TM.xml
<txnmgr name="Txn" logger="Q2" class="org.jpos.transaction.TransactionManager"  realm="transaction-manager">
    <property name="space" value="tspace:default" />
    <property name="queue" value="ROL.TXN" />
    <property name="sessions" value="40" />
    <property name="debug" value="true" />

    <participant class="isogateway.transaction.Switch" logger="Q2" realm="switch" >
        ...
    </participant>

    <group name="AutorizacaoBloqueio">
        ...
    </group>


</txnmgr>

Alejandro Revilla

unread,
Oct 27, 2014, 8:44:53 PM10/27/14
to jPOS Users
Felipe,

I suggest you take a look at the ChannelAdaptor that takes care of the low level handling of a channel. You should not have to call ISOChannel.receive, the adaptor takes care of that.

Take a look at the clientsimulator in jPOS-EE for a sample setup.

There's some documentation here: http://jpos.org/doc/jPOS-EE.pdf



--
--
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/5a3f5fe4-2a7b-48de-a814-9bb3e94b13ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Felps

unread,
Oct 28, 2014, 9:37:19 AM10/28/14
to jPOS Users
Tks Alejjandro, I'll try the client simulator.

Just one more thing, my real client isn't a jPOS application. Can I use a client based on raw socket connection to send/receive ISO to my jPOS server?
To unsubscribe, send email to jpos-users+unsubscribe@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+unsubscribe@googlegroups.com.
--
--
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+unsubscribe@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 a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/7MimyOv6W_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3DmJUcWceBo7xnqkExsy%3DBnaXrr1wDWeuv7q27UakoULtg%40mail.gmail.com.

Alejandro Revilla

unread,
Oct 28, 2014, 10:04:43 AM10/28/14
to jPOS Users
Sure, why not.

Felipe Senefonte

unread,
Oct 29, 2014, 4:57:14 PM10/29/14
to jpos-...@googlegroups.com
Tks Alejandro.

I did some changes and now I know where´s the problem.

My Db is throwing some exceptions and the Txn send the ABORTED message.

Exception:
    org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:154)
        at isogateway.model.persistence.AccessLogDAO.addLog(AccessLogDAO.java:29)
        at isogateway.transaction.TransactionParticipant.logIsoDB(TransactionParticipant.java:91)
        at isogateway.transaction.RecebimentoEletronico.process(RecebimentoEletronico.java:105)
        at isogateway.transaction.TransactionParticipant.doPrepare(TransactionParticipant.java:40)
        at org.jpos.transaction.TxnSupport.prepare(TxnSupport.java:44)
        at org.jpos.transaction.TransactionManager.prepare(TransactionManager.java:473)
        at org.jpos.transaction.TransactionManager.prepare(TransactionManager.java:526)  <debug>

        at org.jpos.transaction.TransactionManager.run(TransactionManager.java:257)
        at java.lang.Thread.run(Thread.java:662)


AccessLogDAO.java: 
 try {
            db.open();
 //line 29:           db.session().getTransaction().begin();  //error occurs here

            AccessLog accessLog = new AccessLog();   
             .....

            logId = (Long) db.session().save(accessLog);

            db.session().getTransaction().commit();
        } catch (Exception e) {
            db.session().getTransaction().rollback();
           e.printStackTrace();
        } finally {
            db.close();
        }


I think I'm trying to open a transaction when one is already open. Can you guys help ? tks!

Alejandro Revilla

unread,
Oct 29, 2014, 5:24:34 PM10/29/14
to jPOS Users
​Nested transactions are not supported by your DB, so you shouldn't use them. You probably want to just use the main transaction.



Felipe Senefonte

unread,
Oct 30, 2014, 1:29:21 PM10/30/14
to jpos-...@googlegroups.com
Hi, I made some changes in my configuration. Now i'm getting this message:

<log realm="close" at="Thu Oct 30 15:10:23 BRST 2014.499" lifespan="31ms">
  <error>
    <exception name="null">
    java.lang.NullPointerException
at org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:155)
at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:91)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1218)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:421)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at org.jpos.transaction.Close.closeDB(Close.java:50)
at org.jpos.transaction.Close.commit(Close.java:36)
at org.jpos.transaction.TransactionManager.commit(TransactionManager.java:484)
at org.jpos.transaction.TransactionManager.commit(TransactionManager.java:425)
at org.jpos.transaction.TransactionManager.run(TransactionManager.java:268)
at java.lang.Thread.run(Thread.java:662)
    </exception>
  </error>
</log>

I'm using the participant org.jpos.transaction.Open and org.jpos.transaction.Close to take care of my transaction.
My participant who calls the database just do this:  getDb().session().save(accessLog);

I have a client who creates 50 threads and call my jPOS server but the thing is that this error occurs once in a while. Somethings the database insert all 50 register, sometimes just 48, 47. Its intermittent.

Looking more closely the Exception is thrown by this class in this method:
AbstractList.java
final void checkForComodification() {
   if (modCount != expectedModCount)
throw new ConcurrentModificationException();
}
The modCount is bigger than expectedCount.

Now that I'm using the Open/Close participants, the session.commit() shouldn't be a problem, right?

att,
Felipe

Alejandro Revilla

unread,
Oct 30, 2014, 1:37:26 PM10/30/14
to jPOS Users
The number of things that can go wrong is big.

Without looking at your custom code, it's very difficult to tell. Make sure you don't have member variables in your participants, and that the number of TransactionManager sessions matches your JDBC pool configuration.




Felipe Senefonte

unread,
Nov 7, 2014, 8:00:32 AM11/7/14
to jpos-...@googlegroups.com
Hi iguys, just to clarify... 

my problem was with my Database. 
After I put the Open and Close participants, the server became stable and the ConcurrentModification exceptions was because some other applications were deleting my data.

tks!

Alejandro Revilla

unread,
Nov 7, 2014, 9:00:50 AM11/7/14
to jPOS Users
Thank you for the heads-up.



Reply all
Reply to author
Forward
0 new messages