Announcement Announcement Module
No announcement yet.
Write XML data into TCP using StaxEventItemWriter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write XML data into TCP using StaxEventItemWriter


    Read flat files - convert the data into xml format - write the data into a TCP port - retrieve response and print on a log file.

    I have used FlatFileItemReader and created suitable Mapper implementation to read the delimited text file. Can we use StaxEventItemWriter to write XML messages into a TCP port? If yes, how do we do that?

    If StaxEventItemWriter does not support writing data to TCP ports, what is the correct way of achieving this objective? Kindly advice.


  • #2
    StaxEventItemWriter can only write to a file. However, you can easily solve your problem by taking the following steps -

    First step: Use StaxEventItemWriter to write to a file.
    Second step: Use java sockets to write to the TCP port.


    • #3
      Thanks for your response.

      We want to avoid creating a temporary file as we expect a huge volume of files to be processed. Is it possible to pass the define a bean to represent the Socket class and inject the InputStream of the Socket as a resource to the StaxEventItemWriter? Is this a good approach?


      • #4
        This might not be the best solution, but I had to "clone and own" a version of the StaxEventItemWriter to be able to write GZipped XML since "open" is private. The amount of code you need to change is minimal though to support it.