How to make an intermediary server that decides to whom the client's request will be forwarded ?

53 views
Skip to first unread message

quenchless mainuddin

unread,
Jun 2, 2015, 5:42:55 AM6/2/15
to jpos-...@googlegroups.com

Hello,
I am suppose to create an intermediary server that can receive requests from a client and take decision to forward that request to other servers. For example, There is a Server-A that is connected to Server-B and Server-C. Now Server-A receives a request from client and forwards it to either Server-B or Server-C. 

Here is the challenge that Server-B has XML Channel on the other hand, Server-C has ASCII Channel. So Server-A should be able to be connected with all the channels from both clients and servers. Once Server-A takes a request from the client, it should check from what channel the request is come in. Then Server-A forward the request based on the decision over clients channel. i.c. If Server-A receive request form XML Channel then it should forward the request to Server-B. 

I have already done some portion. Whenever Server-A takes request, it will forward the request to Server-B. But I need also to forward it Server-C. I am giving a flow diagram to make my problem more understandable. 

How can I make intermediary Server-A that can receive request from client with one channel and forward the request to another server based on the connection between the servers ? 


my problem.PNG

chhil

unread,
Jun 2, 2015, 6:44:58 AM6/2/15
to jpos-...@googlegroups.com

The way I see it,  your intermediary box has to be a server for clients A and B and has be a clients for Servers A and B.

Now consider your intermediary box that connects to servers A and B. 
You will have a mux associated with each if the channels connecting to server A and server B, let's call them muxA and muxB.  These names are configured in each of mux deploy files.

Now you can determine which mux to use for sending a message based on content of received message.
You would query the name registrar by the mux name,  get the object and use it to send the request.

-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/d3ce8227-df11-4fab-b642-ca37513e26d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

quenchless mainuddin

unread,
Jun 2, 2015, 7:27:05 AM6/2/15
to jpos-...@googlegroups.com
But what would be muxA and muxB configuration ? could you please give me an example writing demo code ? 

Thanks for the instant response. 

chhil

unread,
Jun 2, 2015, 8:57:36 AM6/2/15
to jpos-...@googlegroups.com

There is another active thread that has a qmux deploy file sample. Please take a look.

Snippet from another thread.

5. Given below  20_xxx_mux.xml used

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="mcpsmux">

 <key>11</key>

<in>mcps-channel-receive</in>

<out>mcps-channel-send</out>

<ready>mcps-channel.ready</ready>

<unhandled>mcpsunhandledqueue</unhandled>

</mux>

You would have 2 of these wrapping the 2 channels in/out spaces.

-chhil

quenchless mainuddin

unread,
Jun 4, 2015, 4:54:18 AM6/4/15
to jpos-...@googlegroups.com
Thanks for your instant response. I have done a little bit portion but still I have the same problem. I am giving source code of my request listener MiddleWare.java

public class MiddleWare implements ISORequestListener{

@Override
public boolean process(ISOSource isoSrc, ISOMsg isoMsg) {
try {
MUX mux = (MUX) NameRegistrar.getIfExists("mux.jpos-clientOne-mux");
ISOMsg reply = mux.request(isoMsg, 10 * 1000);
if (reply != null) {
System.out.println("Processor One");
System.out.println(new String(reply.pack()));
reply.set(125, "RESPONSE FROM SERVER A");
isoSrc.send(reply);
return true;
}
                       

                       mux = (MUX) NameRegistrar.getIfExists(mux.jpos-clientOne-mux);
                       if(mux.isConnected()){
reply = mux.request(isoMsg, 10 * 1000);
if(reply != null){
System.out.println("Processor Two");
System.out.println(new String(reply.pack()));
reply.set(125, "RESPONSE FROM SERVER B");
isoSrc.send(reply);
return true;
}
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}

The configuration file for the middleware server, 10_server.xml

<server class="org.jpos.q2.iso.QServer" logger="Q2" name="MyISOServer">
    <attr name="port" type="java.lang.Integer">15500</attr>
    <attr name="maxSessions" type="java.lang.Integer">200</attr>
    <attr name="minSessions" type="java.lang.Integer">100</attr>

    <channel name="XMLClientChannel" class="org.jpos.iso.channel.XMLChannel" logger="Q2"
             packager="org.jpos.iso.packager.XMLPackager"
             header="000000000000">
    </channel>
    
     <channel name="NACClientChannel" class="org.jpos.iso.channel.NACChannel" logger="Q2"
              packager="org.jpos.iso.packager.ISO87BPackager" 
              header="000000000000">
     </channel> 

    <request-listener class="com.test.latest.middleware.ServerAListener" logger="Q2">
        <property name="space" value="transient:default" />
        <property name="queue" value="TransactionQueue" />
        <property name="timeout" value="10000" />
    </request-listener>
</server>

15_channel.xml - 

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

<channel-adaptor name='jpos-client-adaptor' class="org.jpos.q2.iso.ChannelAdaptor"
logger="Q2">
<channel class="org.jpos.iso.channel.XMLChannel" logger="Q2"
packager="org.jpos.iso.packager.XMLPackager" header="000000000000">

<property name="host" value="127.0.0.1" />
<property name="port" value="12345" />
</channel>
<channel class="org.jpos.iso.channel.NACChannel" logger="Q2"
packager="org.jpos.iso.packager.ISO87BPackager" header="000000000000">

<property name="host" value="127.0.0.1" />
<property name="port" value="23456" />
</channel>
<in>jpos-client-send</in>
<out>jpos-client-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

20_mux.xml - 

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

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="jpos-clientOne-mux">
<in>jpos-client-receive</in>
<out>jpos-client-send</out>
</mux>

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

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="jpos-clientTwo-mux">
<in>jpos-client-receive</in>
<out>jpos-client-send</out>
<unhandled>jpos-client-unhandled</unhandled>
</mux>

N:B: I don't know how <key> works. would you please explain about the <key> tag ? I am sorry to say that I am a beginner and trying to learn accurately. But how jpos structure works? how xml file works? when will the java file be called ? how can I make a server that supports multiple channels ? I have read proguid.pdf to learn JPOS but could not find something that clears my concept. If you help me out then I will be so thankful to you. 

Thanks & Regards

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/1_QM5Q9ezwo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAPazefDGotLa2kEkqHq7GnZowd1epxw2xETJDTqYkhQVn0nd0w%40mail.gmail.com.

chhil

unread,
Jun 4, 2015, 6:57:15 AM6/4/15
to jpos-...@googlegroups.com
I am not sure what does have the same problem means?
In your code the second mux call is not finding mux 2 but mux1 instead.
Your server deploy cannot use one port to listen on and use 2 channel packagers, how would the server know which channel/packager combination to use when a message arrives?

You may consider having 2 servers, one for XML channel and its packagager and the another for NACChannel and its packager.



As for understanding jpos, http://jpos.org/doc/proguide-draft.pdf has been shared a lot of times on this list. 

-chhil

quenchless mainuddin

unread,
Jun 4, 2015, 7:43:26 AM6/4/15
to jpos-...@googlegroups.com
I read the book already that you have given to me. But In this book, I found nothing about how xml file works collaborating with java file as well as the details about xml configuration that can help me to solve my problems. I thought i had to distinguish clients and match with servers based on the channel connected to my Middle-ware. Probably, I was in the wrong track. So please give me the right way of thinking that improve my concepts. 

"In your code the second mux call is not finding mux 2 but mux1 instead."
That's the main problem what i am facing now. I have to find mux 2 instead of mux 1 but how ? My problem scenario - 

1. Making a Middle-ware that receives request from client-A and sends to Server-B.
2. Identifying clients based on their IP or channel by which they are connected to my Middle-ware.
3. Identifying servers based on their IP or channel by which they are connected to my Middle-ware.

These are what i wanted to do. But i am stuck now. It seems to me that i am continuously swimming in the ocean and don't know where i am. 

Reply all
Reply to author
Forward
0 new messages