This discussion is archived
5 Replies Latest reply: Jan 20, 2010 1:29 AM by 843830 RSS

String Arrays in BPEL? pls help! JCAPS 6, JBI

843830 Newbie
Currently Being Moderated
Hi.

I've got a problem im finding really difficult to solve.

I need to receive a CSV file and manipulate it. Im finding it difficult since there doesnt seem to be string array capabilities in BPEL for a string.

So for example, if the input file contains the following information:

Mark,1983,January,consultant
John,1984,February,architect
Stacy,1985,March,doctor
Mike,1986,April,nurse
Jones,1987,May,engineer

I need to parse through the data and reach the following output in a string
(Basically delete 2 of the 5 columns)

Mark,consultant
John,architect
Stacy,doctor
Mike,nurse
Jones,engineer


I can do it with one line quite easily with simple substringBefore and substringAfter expressions.

But how do i loop through the entire file, line by line, without using string arrays.
Note: the file could contain thousands of lines.

Thanks in advance
  • 1. Re: String Arrays in BPEL? pls help! JCAPS 6, JBI
    805007 Newbie
    Currently Being Moderated
    If you go to the extent of using BPEL, rather then perl or some such, then you need to go all the way.
    I assume here that you are using OpenESB, GlassFish ESB, of Java CAPS/JBI, that is BPEL 2.0 environment.
    Define one XML Schema document whose input message structure corresponds to the input CSV and one whose message structure corresponds to the output CSV.
    Define custom delimiters on both structures, to be used by the Custom Encoder
    Create WSDLs for the inbound and the outbound side and configure them to use the custom encoder to "decode" CSV to XML on the way in and to "encode" XML to CSV on the way out.
    In BPEL, map from XML to XML.

    Regards

    Michael

    PS.
    There are a number of tutorials on encoder aspects of teh JBI kit. Even one from me: http://blogs.sun.com/javacapsfieldtech/entry/java_caps_6_jbi_note2
  • 2. Re: String Arrays in BPEL? pls help! JCAPS 6, JBI
    843830 Newbie
    Currently Being Moderated
    Hi. Yes that is an option we have looked at.
    However we were having performance issues and making xml objects for each element in the flatfile will give us serious issues. Remember, there could be tens of thousands of records.

    I have received some guidance. Another suggestion was to use the Javascript Assign function. So I can use the split function and make an array and manipulate the string (Just like normal java code)

    However there is not much documentation on how to use it. So I'm struggling with the basic functionality of the javascript assign.

    Any help again would be appreciated
  • 3. Re: String Arrays in BPEL? pls help! JCAPS 6, JBI
    805007 Newbie
    Currently Being Moderated
    Fair enough. I am no great fan of XML myself.
    Try: "GlassFish ESB v2.1 - Using JavaScript Codelets to Extend BPEL 2.0 Functionality" at http://blogs.sun.com/javacapsfieldtech/entry/glassfish_esb_v2_1_using and "GlassFish ESB v2.1 Field Notes - JavaScript Codelets to Make BPEL Process Wait for a Random Duration Up to a Maximum number of Milliseconds" at http://blogs.sun.com/javacapsfieldtech/entry/glassfish_esb_v2_1_field to see if this gives you enough information to deploy a JavaScript script to do the splitting. If you are still having difficulties, ping me.

    Regards

    Michael
  • 4. Re: String Arrays in BPEL? pls help! JCAPS 6, JBI
    805007 Newbie
    Currently Being Moderated
    The links I provided earlier will be good for getting JavaScript to work. I have some questions, however.
    I assumed you are reading a multi-record file using the File BC, having File BC break up the file into records and getting each record delivered to a separate BPEL instance. This would be a "normal" way of dealing with multi-record files where each record needs be processed individually.
    It is possible to read an entire file as a single payload blob, pass it to BPEL and have BPEL deal with breaking up into records, processing each record and re-assembling the result into a payload blob to be written to somewhere. This can be done using JavaScript Assign as well. If your file is anything more then about 100Mb you will have memory issues. If you have other solutions running in the same app server you will have memory issues before you get that far. So this kind of solution has a self-destruct mechanism built in. If you keep payload size within reasonable limits you may be able to get away with this.
    I am very curious as to why you are trying to use BPEL for this. I would consider doing this in Java, if I have to deploy the solution to the application server. Since you seem to be expecting to get the whole payload as a blob and process it, there does not seem to be anything else the BPEL process would be doing, so why use a BPEL process in the first place? Or am I interpreting what I think you said incorrectly?

    Regards

    Michael
  • 5. Re: String Arrays in BPEL? pls help! JCAPS 6, JBI
    843830 Newbie
    Currently Being Moderated
    Very helpful. THanks alot