# Java output plugin : How to encode values using existing codec

**URL:** <https://discuss.elastic.co/t/java-output-plugin-how-to-encode-values-using-existing-codec/186036>\
**Category:** Logstash\
**Created:** [June 17, 2019, 10:06am UTC](https://discuss.elastic.co/t/java-output-plugin-how-to-encode-values-using-existing-codec/186036 "2019-06-17T10:06:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Pawar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_pawar/32/44371_2.png) [@Rahul\_Pawar](https://discuss.elastic.co/u/Rahul_Pawar)\
**Post date:** [June 17, 2019, 10:06am UTC](https://discuss.elastic.co/t/java-output-plugin-how-to-encode-values-using-existing-codec/186036/1 "2019-06-17T10:06:32Z")

</div>

Writing java output plugin and need to convert values into the user-specified codec. Maybe JSON, AVRO.  
Question is can I use existing ruby written codec or need to create my own?  
Even if we have written java codec then how we can use into output java plugin?

sample code

```
@Override
public void output(final Collection<Event> events) {
     Iterator<Event> z = events.iterator();
      while (z.hasNext() && !stopped) {
             //How to use existing or newly created java codec here. Ex. Json, Avro
        }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 15, 2019, 10:06am UTC](https://discuss.elastic.co/t/java-output-plugin-how-to-encode-values-using-existing-codec/186036/2 "2019-07-15T10:06:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
