Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

jpos - PostChannel

96 views
Skip to first unread message

Kumar Kaliappan

unread,
Mar 7, 2025, 2:17:46 PMMar 7
to jPOS Users
Hi team,

I am totally new to jpos and ISOMsg. By referring the existing source code, I am trying to create rest service with springboot version 3.4.3 and jdp 17. From where I am trying to send ISOMsg.

The ISO request is provided as binary file to me. Hence I read the binary file and create the ISOMsg object and send using PostChannel(PostChannel is used already for this purpose). I understood from the existing source code that channel will create 2 bytes length in the start of the message. In my case, I need to increase 2 bytes in the length. 

If the message length is 39, then first 2 bytes should contain 39+2=41. 

My source code:
//bank requires a 12 byte header be included for all communications = "ISO023400070"
private final byte[] bHeader = {'I','S','O',0x30,0x32,0x33,0x34,0x30,0x30,0x30,0x37,0x30};
final BaseChannel channel;
final ISOMsg isoRequest = new ISOMsg();
logger.info("Verify packager");
if (jposPackager == null) {
throw new ISOException("Null Packager");
}
channel = new PostChannel(host, port, jposPackager);
channel.setTimeout(timeout);
channel.setLogger(jposLogger, "org.jpos");
channel.setHeader(bHeader);
File file = ResourceUtils.getFile("classpath:"+binFileName);
byte[] isoByteMessage = Files.readAllBytes(file.toPath());
isoRequest.setPackager(jposPackager);
        isoRequest.unpack(isoByteMessage);
        channel.connect();
        channel.send(isoRequest);
        final ISOMsg isoResponse = channel.receive();

My requirement is, I need to increase the length as (length of the message +2) in the first 2 bytes.

Is it possible to add the length in the first 2 bytes while creating the request. Please help me on this.

Regards,
Kumar

chhil

unread,
Mar 7, 2025, 3:07:02 PMMar 7
to jpos-...@googlegroups.com
Use the nacchannel. It has a property to add the length of length to the length.
Postchannel and naccchannel are interchangeable with additional config in the nacchannel.


https://github.com/jpos/jPOS/blob/main/jpos/src/main/java/org/jpos/iso/channel/NACChannel.java#L124
-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
---
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 visit https://groups.google.com/d/msgid/jpos-users/f6ba91d5-93dd-4532-91a4-a399df2a68edn%40googlegroups.com.

Kumar Kaliappan

unread,
Mar 9, 2025, 8:58:38 AMMar 9
to jPOS Users
Hi chhil,

Thanks for the quick reply.
I used NACChannel instead of PostChannel and also added the below code.

SimpleConfiguration cfg = new SimpleConfiguration();

cfg.put("include-header-length", Boolean.TRUE);

channel.setConfiguration(cfg);


I hope this is the change you suggest for this adding length. Right?

Regards,
Kumar

Mark Salter

unread,
Mar 9, 2025, 9:16:21 AMMar 9
to jpos-...@googlegroups.com

>> I hope this is the change you suggest
>>  for this adding length. Right?

try it and see.

You did not share if your file held just the message or the length as well, but you can  heck this and strip it off if needed.

-- 
Mark



-------- Original Message --------
signature.asc

Kumar Kaliappan

unread,
Mar 10, 2025, 2:24:42 PMMar 10
to jPOS Users
Hi Mark,

My file just holds the message. Not the length.

Regards,
Kumar

Alejandro Revilla

unread,
Mar 10, 2025, 9:26:13 PMMar 10
to jpos-...@googlegroups.com
While you can do all this programmatically, you are missing some jPOS features. You could use DirPoll to drop your file into a directory and get jPOS to send it using a MUX and a Channel to your destination. You may want to take a look at https://jpos.org/docs/category/tutorial



Kumar Kaliappan

unread,
Apr 1, 2025, 4:46:23 AMApr 1
to jPOS Users
Hi team,

Thanks for the information about MUX and Channel features in jpos. I will look into it and use it if require.

Currently I am working on PoC, I use bin file to keep my request info and reading it to construct ISOMsg. But in real, it will be Springboot app and will receive ISOMsg in its endpoint. 

My intial clarity: I need to send ISOMsg request to Payment processor and (length of the message+2) to be added in the first 2 bytes. And I was asked to use the NACChannel instead of PostChannel. I think PostChannel will add length of the message in the first 2 bytes. 

Now I am using NACChannel instead of PostChannel to send the ISOMsg request to Payment processor. When I tested, I see both NACChannel and PostChannel will give the same length when I read the first 2 bytes from the byte array.

I need one clarity here. Do I need to override the method sendMessageLength(int len) in my source code?

chhil

unread,
Apr 1, 2025, 6:03:39 AMApr 1
to jpos-...@googlegroups.com
Simple test that works. Make sure you set the include-header-length as a string "true". This is because jpos runs via xml deploy files and these properties are read from the xml file as strings and converted to booleans.

You can do a simple test with cfg.getBoolean(propertyname) for a string value and a boolean value. 

public static void main(String[] args) throws IOException, ISOException {
NACChannel c = new NACChannel(new ISO87APackager(),null);
SimpleConfiguration cfg = new SimpleConfiguration();
cfg.put("include-header-length","true");
cfg.put("host" , "127.0.0.1");
cfg.put("port", "9991");
c.setConfiguration(cfg);
ISOMsg m = new ISOMsg("0200");
c.connect();

c.send(m);
}


At the other end I have ncat running and dumping hex. You can see the length is 6 when a 4 byte mti is sent
ncat -l -p 9991 | xxd
00000000: 0006 3032 3030                           ..0200



Reply all
Reply to author
Forward
0 new messages