Dynamic Packager with ISOField

Skip to first unread message


Nov 25, 2021, 9:22:48 AM11/25/21
to jPOS Users
Hi there!
I have a question related to the usage of dynamic packager, the thing is that I need to differentiate between two types of message because the structure of them (The packagers) are different.

I based on this question HERE

But i can't differentiate with the headers, i need to use one of the fields that came in the request. How can I accomplish that? So far I have something like this:


<server class="util.CustomQServer" logger="Q2" name="server">
   <attr name="port" type="java.lang.Integer">${server.port}</attr>
   <channel name="clientChannel" class="util.CustomChannel"
           logger="Q2" type="server"
           packager="org.jpos.iso.packager.GenericPackager" header="6000000000">
          <property name="packager-config" value="cfg/Packager1.xml" />
          <request-listener class="Listener" logger="Q2">
          <property name="space" value="tspace:default" />
          <property name="queue" value="Queue" />
          <property name="timeout" value="60000" />


public class CustomChannel extends NACChannel {

   protected ISOPackager getDynamicPackager(byte[] header, byte[] message) {

       try {
          if(----> i need the field 48 <----){
              packager = new GenericPackager("cfg/Packager2.xml");
          }else {
              packager = new GenericPackager("cfg/Packager1.xml");
            return packager;
       } catch (ISOException e) {
     return null;

Thanks in advance!


Nov 26, 2021, 8:32:08 AM11/26/21
to jPOS Users
For anyone interested, I solved it as follows:

    protected ISOPackager getDynamicPackager(byte[] header, byte[] message) {
        ISOPackager packager1 = null;
        packager1 = isPackager("cfg/Packager1.xml", message, "pack1");
        if(packager1 == null){
            return isPackager("cfg/Packager2.xml", message, "pack2");
            return packager1;
    public ISOPackager isPackager(String rutaPackager, byte[] message, String type){
             ISOMsg iso = new ISOMsg();
             iso.setPackager(new GenericPackager(rutaPackager));
             return iso.getPackager(); 
        }catch (ISOException e){
             System.out.println("An exception occurred, it is not the integration packager "+type);
             return null;

murtuza chhil

Nov 29, 2021, 9:15:18 PM11/29/21
to jPOS Users
When the exception is thrown it could be for a problem with any field (before or after the field you are doing the check on).
What you could is, in the catch, check the ISOMsg and see if your field is present. The isomsg gets populated upto the point the exception is thrown. But still there is no guarantee that the data in your field is valid.


Reply all
Reply to author
0 new messages