Transmission of large chunks of data


I am trying to do the following:

  1. query a customer erp system for item or customer master data
  2. loop through the results and build an xml document (just a long concatenated string)
  3. transmit resulting xml document to the target system

My problem is that I can’t make it perform. The sql query is fairly fast (maybe 1 minute), and the transmission is fast as well. However, the looping through and putting into an xml string is very slow. For about 40,000 records with about 24 elements each, it takes a little over 24 hours. I must be missing something. We are using IS 6.1 on a fast windows server (3GHz) with the maximum amount of memory. Any suggestions would be appreciated.


Have you tried picking up the result set and directly converting to XML as is from the IData Structure? How much time does that take. This XML Structure may not be what you expect, but it will still be an XML.

The next thing to try is, if you have an XSLT that you can apply on the generated XML to create your required XML, and perform that using Java or WmXSLT, what time would it take?


I’m just guessing at your code, but if you’re doing 40000 individual string concatentations, and assuming that each customer record produces an XML fragment of N characters, then over the course of the loop, Java will need to allocate 800,020,000 x N chars of storage. That will take some time, and put a big load on the GC. 24 hours worth, even :slight_smile:

(BTW, the same sort of issue applies to incrementally building string or document lists, as WM implements them internally as arrays, and creates new copies when the list is extended.)

You’d be better off creating a single StringBuffer of 40000 x N chars, and appending the XML fragments to it, or breaking the extract into multiple parts. You could wrap the StringBuffer in some services to allow it to be used in Flow, or you could just do the whole construction job in a single Java service.


For the string buffer stuff:

I certainly think you can get it down from 24 hours!

How are you converting into XML? If you’re doing it by hand with concat or something, then try using documentToXMLString.

If that’s not satisfactory try using the string buffer stuff (in the link above) and make it by hand then… It should be pretty quick…