Filepolling Question

Hello all

in file polling monitoring Directory , i am expecting different file structures ( xmls)

based on which i have to map different canonical s ,

how can i find the document type from the stream to map accordingly

thanks in advance

You’ll need to infer the doc type from the filename or the file contents.

Often people want to use one directory for every type of file. A sort of “master” inbound directory. Alas, this usually isn’t a good approach for a variety of reasons. I would recommend considering using different directories and file polling ports for different doc types–one doc type, one file polling port for only that type.

Sadly Different folder structure or different filenames as all of them have same name pattern …

so can you please let me know how to infer contents before converting to document type as i have set arrays option as true which requires to provide the document type name


Assign folder A to be the “inbox” for doc type A. Port A invokes service A, which assumes doc type A.
Assign folder B to be the “inbox” for doc type B. Port B invokes service B, which assumes doc type B.
And so on.

Thanks for the Suggestion,

but all the files would be placed in a single folder … with single file polling port

hence i want to find the way to find the document type from the input stream



What is driving the desire to put all files into a single folder?

Here are reasons to not do that:

  • Mingling of different types of files from different partners/applications can lead to mishandling of data/files.
  • The code to determine the type of file is more complex.
  • Cannot suspend processing for just one type of file/integration. It is all or nothing.

That said, you can potentially do document recognition by examining the first 100 to 1000 bytes of the file. Open the file as stream and read however many bytes to get to data that you can use to determine the document type. Then you can close and reopen the file and process it with the right document type in the node to doc call.

its an legacy interface where application used to consume all the files from single folder .and client is Reluctant to change in that end …

and as a solution i m routing the files to TN ,

so i can now suspend any particular transaction if needed

Since you mentioned these were XML files, your file polling port service doesn’t need to do anything. Just pass the stream to TN and it will recognize the doc type using your TN document type definitions.

:slight_smile: done the Same , results are as expected

thanks for your help