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

  • Write XML data into TCP using StaxEventItemWriter

    Hi

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

    Question:
    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.

    Thanks
    Chandra

  • #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.

    Comment


    • #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?

      Comment


      • #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.

        Comment

        Working...
        X