# Write data issue using java pipeline transform code and load data from kafka

**URL:** <https://www.singlestore.com/forum/t/write-data-issue-using-java-pipeline-transform-code-and-load-data-from-kafka/6373>\
**Category:** Connectors and Pipelines\
**Tags:** pipelines, developer\
**Created:** [January 5, 2023, 7:21pm UTC](https://www.singlestore.com/forum/t/write-data-issue-using-java-pipeline-transform-code-and-load-data-from-kafka/6373 "2023-01-05T19:21:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhuri.kotha](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/3d9bf3/32.png) [@madhuri.kotha](https://www.singlestore.com/forum/u/madhuri.kotha)\
**Post date:** [January 5, 2023, 7:21pm UTC](https://www.singlestore.com/forum/t/write-data-issue-using-java-pipeline-transform-code-and-load-data-from-kafka/6373/1 "2023-01-05T19:21:35Z")

</div>

Hi Singlestore,

We are trying to load the data from Kafka and transform using the java application. We are running the java jar file from the bash script.

**Pipeline**

```auto
CREATE PIPELINE test_pipeline_transform
    AS LOAD DATA KAFKA '<kafka-hostname:port>/<topic-name>'
    WITH TRANSFORM('https://xxxx/xxxx/maven-app-transform.tar.gz','executable.sh','') 
    INTO TABLE test_table;

```

**Bash script passed to the transform(maven-app-transform.tar.gz/executable.sh)**

```auto
#!/bin/bash
java -jar $( dirname -- "$0"; )/my-app-1.0-SNAPSHOT.jar "$@"

```

**Java file**

```auto
public class App
{
    public static void main( String[] args ) throws IOException {
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
        String input = readInput();
        List<String> records = new ArrayList<>(Arrays.asList(input.substring(1).split("\n")));
        for (String row : records) {
            List<String> cellList = new ArrayList<>(Arrays.asList(row.split(",")));
            String output = "";
            for (String cell : cellList) {
                output += cell + ",test-" + cell + "-123\n";
            }
            bufferedWriter.write(output);
        }
        bufferedWriter.flush();
    }

    public static String readInput() throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder output = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            output.append(line);
            output.append("\n");
        }
        bufferedReader.close();
        return output.toString();
    }
}

```

**Published below messages in kafka topic**

```auto
test 123
new line value
abc

```

We are able to transform the text. But we are getting one extra character in the first inserted message table as below. If we skip the first character in the java code then we are not getting the extra character.

![image](https://forum-prod-assets20231213123829991800000001.s3.dualstack.us-east-1.amazonaws.com/original/2X/f/f20999025019c64964d0b0ad1f988027297eed39.png)

Is the above approach correct or did I miss anything?  
Please share any references for the pipeline transform using java if there are any.

Configurations:

- Singlestore version - 8.0.4

- Setup using cluster in a box

- Red hat OS

- Java version - 11

Thanks in advance

---

<div class="post-metadata">

**Author:** ![arnaud](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arnaud](https://www.singlestore.com/forum/u/arnaud)\
**Post date:** [January 6, 2023, 4:37pm UTC](https://www.singlestore.com/forum/t/write-data-issue-using-java-pipeline-transform-code-and-load-data-from-kafka/6373/2 "2023-01-06T16:37:26Z")

</div>

Hello, that might be a collation issue. What character would you expect there?

---

<div class="post-metadata">

**Author:** ![madhuri.kotha](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/3d9bf3/32.png) [@madhuri.kotha](https://www.singlestore.com/forum/u/madhuri.kotha)\
**Post date:** [January 6, 2023, 7:26pm UTC](https://www.singlestore.com/forum/t/write-data-issue-using-java-pipeline-transform-code-and-load-data-from-kafka/6373/3 "2023-01-06T19:26:10Z")

</div>

“test 123” is expected. But there is one extra value(?) as highlighted before the “test 123” value.

---

<div class="post-metadata">

**Author:** ![arnaud](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arnaud](https://www.singlestore.com/forum/u/arnaud)\
**Post date:** [January 9, 2023, 6:11am UTC](https://www.singlestore.com/forum/t/write-data-issue-using-java-pipeline-transform-code-and-load-data-from-kafka/6373/4 "2023-01-09T06:11:55Z")

</div>

Could it be related to the same issue as here? [Two strange bytes at the beginning of each message of a Kafka message produced by my Kafka Connector - Stack Overflow](https://stackoverflow.com/questions/44331617/two-strange-bytes-at-the-beginning-of-each-message-of-a-kafka-message-produced-b)
