JPOS Client Multi Threading

388 views
Skip to first unread message

Joe Hackett

unread,
Nov 30, 2016, 4:56:54 PM11/30/16
to jPOS Users
I have been trying to multithread the send/receive process with jposClient and I'm not able to achieve it. So the question is how can I have few threads send and receive messages independently.
I have a main class that does the network message/ key exchange and a different class(executors) to send/receive the financial message. I call the executor class in a loop as a separate thread from the main class by passing few parameters and the handback name. The first request goes thru but the subsequent request fails with this exception: 

org.jpos.iso.ISOException: Duplicate key 'jpos-client-send.02000000000NH000777001879.req' detected.
        at org.jpos.q2.iso.QMUX.request(QMUX.java:259)
        at us.extendit.JposClient.sendRequest(JposClient.java:35)
        at us.extendit.ThreadedClientWorker.sendRequest(ThreadedClientWorker.java:110)
        at us.extendit.ThreadedClientWorker.run(ThreadedClientWorker.java:62)
        at java.lang.Thread.run(Thread.java:745) 

Any help would be much appreciated.

Thanks
Joe

Andrés Alcarraz

unread,
Nov 30, 2016, 4:59:25 PM11/30/16
to jpos-...@googlegroups.com

You are sending more than one message with the same key before it gets responded o timeout. That's all I can guess with what you posted.

Regards


El 30/11/16 a las 18:56, Joe Hackett escribió:
--
--
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 post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/9f0c159b-f7bd-4811-80fd-c8a53bab36bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joe Hackett

unread,
Nov 30, 2016, 5:05:38 PM11/30/16
to jPOS Users
Did you mean this highlighted part?

public void sendRequest(){
JposClient clientbi = (JposClient) NameRegistrar.getIfExists("requester");
clientbi.sendRequest(create200ReqMsg(), "Testing"+i, "jpos-client-mux");
ISOMsg responsebi = clientbi.getResponse("Testing" +i);
Assert. assertNotNull("response is not null", responsebi);

Andrés Alcarraz

unread,
Nov 30, 2016, 5:08:58 PM11/30/16
to jpos-...@googlegroups.com

How the hell would we know what your create200ReqMsg, sendRequest and getResponse methods do? But guessing from the results and your code you are creating messages that have the same key (usually fields 11 and 41).



El 30/11/16 a las 19:05, Joe Hackett escribió:

Joe Hackett

unread,
Nov 30, 2016, 5:26:15 PM11/30/16
to jPOS Users
aha.. awesome. bit11 was the culprit. Value was hardcoded. Made it dynamic and it works now. Thanks a lot for your help.

chhil

unread,
Dec 1, 2016, 12:10:19 AM12/1/16
to jpos-...@googlegroups.com

I have been trying to multithread the send/receive process with jposClient and I’m not able to achieve it.


Kind of feels like you are reinventing the wheel here.
If you use the TransactionManager, you would not have to worry about this. You would create a participant that does the mux logic to send request and receive a response. The TransactionManager creates its threads based on the number of sessions you want to handle to process the messages. Each message will get processed in its own thread while messages in excess of the sessions will sit in the txn mgr space and get processed as soon as a session becomes available.

-chhil



To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages