Creating New Threads Per Connection on QMUX

303 views
Skip to first unread message

SUNNYben

unread,
Nov 3, 2014, 11:33:05 AM11/3/14
to jpos-...@googlegroups.com
Hello Everyone,

I have implemented a concentrator application that receives transactions from terminals and pass it on to a switching server for processing, using Q2 MUX. 

The challenge I have is that the transactions from different terminals reach the switch on the same connection but the switch expects each terminal to bind with its own connection thread.

I would like to ask how best to modify my code so that a connection thread is opened to the switch from the mux for each terminal.

Find below the code snippet, mux config and channel-adaptor configuration i'm using:

MUX mux = (MUX) NameRegistrar.get("mux.mymux");

....................................
public boolean process(ISOSource isosource, ISOMsg isomsg) {

   
ISOMsg response = mux.request(isomsg, InitializeConfig.getMuxTimeOut() * 1000);
   
if (response != null)
        isosource
.send(response);

}


<?xml version="1.0" encoding="UTF-8"?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="mymux">
 
<in>switch-receive</in>
 
<out>switch-send</out>
</mux>

<channel-adaptor name="access-channel-adaptor"
   
class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
       
<channel class="org.jpos.iso.channel.PostChannel" logger="Q2"
   
packager="org.jpos.iso.packager.GenericPackager">
       
   
<property name="host" value="switch-host" />
   
<property name="port" value="1010" />    
   
<property name="packager-config" value="cfg/packager/switchpostilion.xml" />
</channel>

<in>switch-send</in>
<out>switch-receive</out>
<reconnect-delay>30000</reconnect-delay>
<space>tspace:default</space>
</channel-adaptor>

Regards,
Tobi

Alejandro Revilla

unread,
Nov 3, 2014, 11:48:40 AM11/3/14
to jPOS Users
The challenge I have is that the transactions from different terminals reach the switch on the same connection but the switch expects each terminal to bind with its own connection thread.

Is that your real challenge or you just want to process transactions from different terminals simultaneously?

If that's the case, you can use the TransactionManager. See chapter 9 here: http://jpos.org/doc/proguide-draft.pdf




chhil

unread,
Nov 3, 2014, 2:45:44 PM11/3/14
to jpos-...@googlegroups.com
You need a channel adaptor per terminal and a mux associated with it.
So if you have 10 terminals you would need 10 channel adaptors and each associated with a mux. The channel adaptors would make unique connections per terminal. This can quickly get out of hand if you try using deploy files. You probably need to do this programatically instantiating these on the fly using some naming convention e.g. use the terminal id as your mux name as and get the mux using the name and sending your message using it.

There are threads that cover a similar scenario, if I recall it was to do with accepting messages from different terminals on its unique connection. Try searching the user group.


-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/CAAgSK%3DnUs4wPB9SU29AT%2BGnK72ojb%2BqyQJDg_ZxwHHB6jDfr8Q%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Nov 3, 2014, 3:05:49 PM11/3/14
to jpos-...@googlegroups.com
http://goo.gl/NYFvfR (search for qmuxes on the fly) has some relevant conversations.

-chhil

SUNNYben

unread,
Nov 3, 2014, 4:54:49 PM11/3/14
to jpos-...@googlegroups.com
Thanks so much. I'll implement the suggestions and get back.

SUNNYben

unread,
Nov 8, 2014, 4:44:15 AM11/8/14
to jpos-...@googlegroups.com
I have created a channel adaptor for each terminal and associated muxes, tested and each terminal now bind on different ports to the switch. The challenge 
 now is that, based on how channel adaptors work, connections are opened to the switch automatically on all those channels once I start the service.  I need something like OneShotChannelAdaptor that does not connect automatically but also does not close the socket until there is no traffic on the channel for specified amout of time.

Thanks in advance.

chhil

unread,
Nov 8, 2014, 11:30:36 AM11/8/14
to jpos-...@googlegroups.com
You will need to write yourself  custom channel adaptor that has the connection disconnection behavior that you desire.

-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.

SUNNYben

unread,
Nov 8, 2014, 12:02:08 PM11/8/14
to jpos-...@googlegroups.com
I thought so too. I have cloned the source, added a new channel adaptor like OneShotChannelAdaptor but doesn't disconnect. I compiled it but couldn't get it to run.

java.util.MissingResourceException: Can't find bundle for base name org.jpos.q2.
QFactory, locale en_US
        at java.util.ResourceBundle.throwMissingResourceException(Unknown Source
)
        at java.util.ResourceBundle.getBundleImpl(Unknown Source)
        at java.util.ResourceBundle.getBundle(Unknown Source)
        at org.jpos.q2.QFactory.<init>(QFactory.java:59)
        at org.jpos.q2.Q2.run(Q2.java:161)

I don't know where the resource is supposed to be.

Thanks.

On Monday, 3 November 2014 17:33:05 UTC+1, SUNNYben wrote:

chhil

unread,
Nov 8, 2014, 12:14:14 PM11/8/14
to jpos-...@googlegroups.com
All I can suggest is step through the code with the original and then with your cloned one. You should be able to figure it out.

-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.

henry

unread,
Nov 9, 2014, 10:45:58 AM11/9/14
to jpos-...@googlegroups.com
Try OneShotChannelAdaptor,

<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor name="access-channel-adaptor" 
    class="org.jpos.q2.iso.OneShotChannelAdaptor" logger="Q2">

SUNNYben

unread,
Nov 12, 2014, 7:24:09 AM11/12/14
to jpos-...@googlegroups.com
Hello all,

Please I'm having challenges building the jPOS source code. It gets stuck after the following message:

org.jpos.iso.packagers.PackagerTestCase > testXMLPackager FAILED
    junit
.framework.AssertionFailedError at PackagerTestCase.java:214
> Building 67% > :jpos:test > 3163 tests completed, 1 failed, 54 skipped

I have also attached screenshot.

@Henry
OneShotChannelAdaptor disconnects after every message. My switch requires a key exchange after every disconnection, which is why this won't work for me.

Thanks.
jpos_build_error.jpg

Alejandro Revilla

unread,
Nov 12, 2014, 2:19:44 PM11/12/14
to jPOS Users
You may want to check the reports in the build/reports directory and see what kind of exception you're getting.



--
--
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.
Reply all
Reply to author
Forward
0 new messages