-
Aug 10th, 2011, 01:35 AM
#1
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
-
Aug 10th, 2011, 05:04 PM
#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.
-
Aug 11th, 2011, 02:26 AM
#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?
-
Aug 11th, 2011, 02:30 PM
#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.
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
-
Forum Rules