Stream Combiner is an application that allows you to create a combined stream. This stream combines / merges entries from all (original) individual stream producers.
There may be 1 to N stream producers
- Each stream producer acts as a server (opens a socket on a host:port)
- Each stream producer sends XML data in a stream, when the stream combiner connects to it
- Each XML record is sent in an ascending timestamp order (e.g. you may never receive a record with older timestamp than the last received record)
- One stream never produces duplicate timestamps
- The stream may not be finite (and may send millions of records over the lifetime of the application)
- Application should be configurable to read data from N hosts:ports (Stream producers)
- Application writes data in JSON stream.
- The data must be written as soon as possible (e.g. when there is certainity that a record with the same timestamp cannot be received from any stream producer)
- Standard output is the expected destination of the output stream.
- Output data is sorted by timestamp
- If several inputs provide data with the same timestamp - amounts should be merged (see data format below)
- Amounts could be positive/negative. And it's very sensitive data - like money. And nobody likes losing money.
- Add a solution in case a stream producer hangs (does not send any data for a long time)
- Imagine that timestamps comparing operation is VERY expensive - try to minimize it's usage
- Project lifecycyle:
- You must use Maven 3.x to build the project.
- You must use JUnit to write tests for the project. Use of any JUnit extensions is allowed.
- Definition of XML format:
<data> <timestamp>123456789</timeStamp> <amount>1234.567890</amount> </data>
- XMLs in stream are separated by new line (
\n
) - Definition of JSON format:
{ "data": { "timestamp":123456789, "amount":"1234.567890" }}