Results 1 to 4 of 4

Thread: Write XML data into TCP using StaxEventItemWriter

Hybrid View

  1. #1

    Default 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. #2
    Join Date
    Jul 2011
    Posts
    16

    Default

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

    Default

    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. #4
    Join Date
    Jul 2007
    Posts
    101

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •