Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleExample - Archiving

This example shows the APL code used in an Analysis agent connected to a forwarding agent expecting input of type MultiForwardingUDRs. In this example, the data is being buffered in the consume block. This makes it possible to route a complete batch to multiple files from the drain block. Note that the execution context needs available memory to buffer the whole file.

Code Block
languagetext
themeEclipse
import ultra.FNT;

bytearray data;

MultiForwardingUDR createMultiForwardingUDR
        (string dir, string file, bytearray fileContent) {
 
    //Create the FNTUDR
    FNTUDR fntudr = udrCreate(FNTUDR);
    fntAddString(fntudr, dir);
    fntAddDirDelimiter(fntudr);//Add a directory
    fntAddString(fntudr, file);//Add a file

    MultiForwardingUDR multiForwardingUDR =
    udrCreate(MultiForwardingUDR);
    multiForwardingUDR.fntSpecification = fntudr;
    multiForwardingUDR.content = fileContent;

    return multiForwardingUDR;
}

beginBatch {
    data = baCreate(0);
}

consume {
    data = baAppend(data, input);
}

drain {
    //Send MultiForwardingUDRs to the forwarding agent
    udrRoute(createMultiForwardingUDR("dir1", "file1", data));
    udrRoute(createMultiForwardingUDR("dir2", "file2", data));
}


...

Info
titleExample - Local Archiving

This example shows the APL code used in an Analysis agent connected to a forwarding agent expecting input of type MultiForwardingUDRs.

Code Block
languagetext
themeEclipse
import ultra.FNT;

MultiForwardingUDR createMultiForwardingUDR
(string dir, string file, bytearray fileContent){

    //Create the FNTUDR
    FNTUDR fntudr = udrCreate(FNTUDR);
    fntAddString(fntudr, dir);
    fntAddDirDelimiter(fntudr);//Add a directory
    fntAddString(fntudr, file);//Add a file

    MultiForwardingUDR multiForwardingUDR =
    udrCreate(MultiForwardingUDR);
    multiForwardingUDR.fntSpecification = fntudr;
    multiForwardingUDR.content = fileContent;

    return multiForwardingUDR;
}

consume {

    bytearray file1Content;
    strToBA (file1Content, "file nr 1 content");

    bytearray file2Content;
    strToBA (file2Content, "file nr 2 content");

    //Send MultiForwardingUDRs to the forwarding agent
    udrRoute(createMultiForwardingUDR
    ("dir1", "file1", file1Content));
    udrRoute(createMultiForwardingUDR
    ("dir2", "file2", file2Content));
}

The Analysis agent mentioned previous previously in the example will send two MultiForwardingUDRs to the forwarding agent. Two files with different contents will be placed in two separate sub-folders in the root directory.


Scroll ignore
scroll-viewportfalse
scroll-pdftrue
scroll-officefalse
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmlfalse


Next subsection: