How to Listen With Multiple Port for Multiple Client in Single Jpos Instance

Is it possible to listen with multiple port for multiple client in single JPOS instance?

You can certainly add multiple q2 servers.

Just add another xml definition of a q2 server in your dist folder, jPOS would immediately pick up the new server and start listening to your specified port.

How can i parse two different iso format in JPOS with two custom packager from one client

If you want to use the same port, you need a special Channel implementation that would override the 'getDynamicPackager' method. It's customary to use different ports for different packagers, though.

Decorating a multi-client webapp

Struts2 provides application scope, for variables which are global to the application.

Load all the customer specific strings into #application scope (I would use spring to do this when the application starts up). From there referencing the strings would be pretty obvious: #application.greeting I don't like the idea of using an interceptor because there is nothing to intercept. I would say for what you are doing application scope is the perfect place. If it is a single client system I can see no reason why anything would be stored in application scope.

Aside: Tiles uses a different template paradigm than site mesh, and they have slightly different purposes. As such the two can be complimentary. Tiles relying on XML definitions can have it's definitions stored in a DB and is definitely less computationally intensive, however where there is interplay between different UI components... or disparate elements appearing on the page you need to use sitemesh. So for basic template needs tiles does everything and is quite easy to understand but say you wanted to make add a certain widget in the middle of the page which relies on JS which needs to be added to the header it would be tricky to do this in Tiles (although the obvious solution is to just roll the JS functionality into one JS file for all possible uses in a particular part of the site).

Asside 2: By using a view technology such as velocity or freemarker in conjunction with tiles it is conceivable to move the entire view layer into a database. I just thought I would mention that as for some maintenance issues that could be extremely beneficial.

How many jobs can jPOS process?

You need to read the jPOS documentation, in particular the TransactionManager. There's a free book you can get at http://jpos.org/learn

jpos : how to handle messages with different headers with different length listening to the same endpoint and using same packager

First of all if you can avoid that, please do it. Do you really need to send two different header lengths for the same application?

As you said it's a third party application I will assume the answer is yes.

Second, by any chance can the application send 22 header length messages to a port different than the 44 header length messages?

If yes, the simplest thing would be to have two servers each configured with a different header. This solution would not require coding.

The other option would involve coding to write your own channel and it's described as follows.

You just need to create your own Channel implementation.

For instance you can extend NACCHannel and override sendMessageHeader and readHeader methods:

public class CustomChannel extends NACChannel {
byte [] len22Header = {(byte)0xf3,(byte)0xf8,(byte)0xf6,(byte)0xf7};
byte [] len44Header = {(byte)0xf4,(byte)0xf5,(byte)0xf6,(byte)0xf7};

protected byte[] readHeader(int hLen) throws IOException {
byte[] header = new byte[22];
serverIn.readFully(header, 0, 22);
if (Arrays.equals(header, len22Header, 0, 4)) {
return header;
}
header = Arrays.copyOf(header, 44);
serverIn.readFully(header, 22, 22);
}

protected sendMessageHeader(ISOMsg m, int len) throws IOException{
byte[] header = m.getHeader();
//assume header is the one to send, and already has 22 or 44 length
//or you can check
serverOut.write(header);
}
}

Then you just use your channel in the server xml instead of NACChannel

<server class="org.jpos.q2.iso.QServer" logger="Q2" name="gwmip-server-7003" realm="bnet-server-8000">
<attr name="port" type="java.lang.Integer">7003</attr>
<channel class="your.package.CustomChannel"
packager="org.jpos.iso.packager.GenericPackager"
type="server"
logger="Q2"
>
<property name="packager-config" value="cfg/packager/CISebcdic.xml" debug="True" />
<property name="timeout" value="180000"/>
</channel>
<request-listener class="org.jpos.iso.IncomingListener" logger="Q2" realm="incoming-request-listener">
<property name="queue" value="GWMIPTXNMGR" />
<property name="ctx.DESTINATION" value="jPOS-AUTORESPONDER" />
</request-listener>
</server>

Send ISOMsg to ISOServer

The best thing you can do is not to use a main class at all, but use the Client Simulator replacing the client simulator deploy descriptor by one that uses a QBean written by you.Chapters 7.4 - 7.6 of the programmers guide. Walk you through the process of creating one, you just need to change the code to get the MUX (you can use the ClientSimulator code as a base to do that) and use it to make a request as the client simulator does.

Here you have an example QBean that sends a request at the start face and prints the response.

package stack.examples;

import org.jpos.iso.ISOMsg;
import org.jpos.iso.MUX;
import org.jpos.iso.packager.ISO87APackager;
import org.jpos.q2.QBeanSupport;
import org.jpos.q2.iso.QMUX;
public class SendMessageQBean extends QBeanSupport{

@Override
protected void startService() throws Exception {
super.startService();
ISOMsg request = new ISOMsg();

request.setMTI("0200");

request.set(2, "16");

request.set(2, "5421287475388412");

request.set(3, "000000");

request.set(4, "400.0");

request.set(7, "0716070815");

request.set(11, "844515");

MUX mux = QMUX.getMUX(cfg.get("dest-mux", "clientsimulator-mux"));
log.info("sending request", request);
ISOMsg response = mux.request(request, cfg.getInt("timeout", 5000));

log.info("received response", response);
}

}

Hope this point you in the right direction.

Also if you really want to write a main for understanding the basic concepts here you have a minimalist code (without muxes, logger, etc).

package stack.examples;

import java.io.IOException;

import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOPackager;
import org.jpos.iso.channel.XMLChannel;
import org.jpos.iso.packager.XMLPackager;

public class JposClient {

public static void main(String[] args) throws ISOException, IOException {
ISOPackager packager = new XMLPackager();
ISOChannel channel = new XMLChannel("localhost", 10000,packager);
channel.connect();
ISOMsg request = new ISOMsg();

request.setMTI("0200");

request.set(2, "16");

request.set(2, "5421287475388412");

request.set(3, "000000");

request.set(4, "400.0");

request.set(7, "0716070815");

request.set(11, "844515");

channel.send(request);

ISOMsg response = channel.receive();

response.dump(System.out, "response:");

}

}


Related Topics



Leave a reply



Submit