# \[Java\] BulkProcessor- custom data in request-response items

**URL:** https://discuss.elastic.co/t/java-bulkprocessor-custom-data-in-request-response-items/105963
**Category:** Elasticsearch
**Created:** [October 31, 2017, 11:22pm UTC](https://discuss.elastic.co/t/java-bulkprocessor-custom-data-in-request-response-items/105963 "2017-10-31T23:22:34Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 6, 2017, 8:24am UTC](https://discuss.elastic.co/t/java-bulkprocessor-custom-data-in-request-response-items/105963/4 "2017-11-06T08:24:37Z")

</div>

The Bulk Java API supports adding a payload to each request:

> <https://github.com/elastic/elasticsearch/blob/6533b165d6c22f9aceab4e0e2340139b211f7b07/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java#L103-L121>

The Bulk Processor supports it as well. See:

> <https://github.com/elastic/elasticsearch/blob/8caf7d4ff8738131ae65cca86869c904d0e5f19b/core/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java#L267-L270>

So I suppose you can add your own needed payload with that method and retrieve it with `request.payloads()`

Doc says that payloads are coming back in the same order as the bulk item requests:

```auto
    /**
     * The list of optional payloads associated with requests in the same order as the requests. Note, elements within
     * it might be null if no payload has been provided.
     * <p>
     * Note, if no payloads have been provided, this method will return null (as to conserve memory overhead).
     */
    @Nullable
    public List<Object> payloads() {
        return this.payloads;
    }

```

I hope this helps.

---

_[View the full topic](https://discuss.elastic.co/t/java-bulkprocessor-custom-data-in-request-response-items/105963)._
