1

I am new to Hazelcast Jet and in my application I am using jdbc source, this source returning List of Map which I have to Sink in one of json file but when I use Sinks.json it create json directory how can I sink it to particular json file? For E.g.

           BatchSource<List<Map<String, Object>> jdbcSource = Sources
            .jdbc(() -> conn,
                (con, parallelism, index) -> {
                   // query execution
           }, r ->  {
                 return this.mapResultSet1(r);
           });
          jdbcSource.writeTo(Sinks.json("/opt/test.json"));

Please let me know how can I sink my result to json file?

user3458271
  • 638
  • 12
  • 31

1 Answers1

2

Consider aggregating the records to a list before sinking to the JSON file.

jdbcSource
    .aggregate(AggregateOperations.toList())
    .writeTo(Sinks.json("directory-where-a-single-file-will-be-created"))
Vlado Schreiner
  • 478
  • 2
  • 5
  • Yes my data is coming from aggregate operations, How can we name that file as there can be multiple files? and it not working giving this error Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonAutoDetect$Value – user3458271 Nov 27 '21 at 05:06
  • This link helped me out to create a json sink: https://jet-start.sh/docs/how-tos/custom-sink – user3458271 Nov 27 '21 at 13:18