# Reuse NodeClient inside prepareRequest plugin method

**URL:** <https://discuss.elastic.co/t/reuse-nodeclient-inside-preparerequest-plugin-method/73873>\
**Category:** Elasticsearch\
**Created:** [February 3, 2017, 3:17pm UTC](https://discuss.elastic.co/t/reuse-nodeclient-inside-preparerequest-plugin-method/73873 "2017-02-03T15:17:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vglazkov](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vglazkov](https://discuss.elastic.co/u/vglazkov)\
**Post date:** [February 3, 2017, 3:17pm UTC](https://discuss.elastic.co/t/reuse-nodeclient-inside-preparerequest-plugin-method/73873/1 "2017-02-03T15:17:32Z")

</div>

Hi!

Is it possible to reuse NodeClient inside prepareRequest plugin method? I want to pin it inside my native code. Will it be safe to use it across multiple threads inside jni or I should every time use new provided client?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [February 3, 2017, 6:41pm UTC](https://discuss.elastic.co/t/reuse-nodeclient-inside-preparerequest-plugin-method/73873/2 "2017-02-03T18:41:48Z")

</div>

Yep, the NodeClient (and TransportClient) is thread safe, so you can share it between multiple threads. That's the preferred way, to reduce overhead and chattiness with the cluster.

---

<div class="post-metadata">

**Author:** ![vglazkov](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vglazkov](https://discuss.elastic.co/u/vglazkov)\
**Post date:** [February 7, 2017, 12:16pm UTC](https://discuss.elastic.co/t/reuse-nodeclient-inside-preparerequest-plugin-method/73873/3 "2017-02-07T12:16:54Z")

</div>

Thanks!

---

<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:** [March 7, 2017, 12:17pm UTC](https://discuss.elastic.co/t/reuse-nodeclient-inside-preparerequest-plugin-method/73873/4 "2017-03-07T12:17:06Z")

</div>

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