You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jesse Gorzinski (Jira)" <ji...@apache.org> on 2021/08/31 19:33:00 UTC

[jira] [Created] (CAMEL-16907) Program Call usability concerns

Jesse Gorzinski created CAMEL-16907:
---------------------------------------

             Summary: Program Call usability concerns
                 Key: CAMEL-16907
                 URL: https://issues.apache.org/jira/browse/CAMEL-16907
             Project: Camel
          Issue Type: Improvement
          Components: camel-jt400
    Affects Versions: 3.11.0
            Reporter: Jesse Gorzinski
             Fix For: 3.12.0


The program call abilities are not very usable. 

When running in binary mode, all parameters must be converted to byte arrays, like so:
{code:java}
        final int usrSpcSize = 16;//16776704;
        final String pgmCallUri = String.format("jt400://*CURRENT:*CURRENt@localhost/qsys.lib/QUSRTVUS.PGM?fieldsLength=20,4,4,%d&outputFieldsIdx=3&format=binary", usrSpcSize);
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() {
                from("timer://foo?period=5000")
                .process( exchange -> {
                    String usrSpc = "MYSPACE   JESSEG    ";
                    Object[] parms = new Object[] {
                        usrSpc.getBytes("Cp037"),  // Qualified user space name
                        intToBytes(1),             // starting position
                        intToBytes(usrSpcSize),    // length of data
                        new byte[usrSpcSize]       // output
                    };
                    exchange.getIn().setBody(parms);
                })
                .to(pgmCallUri)
                .process( exchange -> {
                    byte[] output = (byte[])((Object[])exchange.getIn().getBody())[3];
                    exchange.getIn().setBody(new String(output, "Cp037").trim());
                })
                .to("stream:out");
            }
        });
{code}
Note, any character output must be explicitly converted from an EBCDIC byte array to a String (but the ccsid is unknown, so the "Cp037" in the above example is just a guess)

In non-binary mode, all input parameters must be text, and I can't figure out how to actually send common data types, most notably integers. 

I will work on and likely send a PR shortly



--
This message was sent by Atlassian Jira
(v8.3.4#803005)