[ 
https://issues.apache.org/jira/browse/NIFI-5982?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Abdou Bourakba updated NIFI-5982:
---------------------------------
    Description: 
When Using the processor  PutElasticsearchHttpRecord,

Nifi send request to Elastic bulk interface. the Request include multiple lines.

If the request fails, we have no indications which of the lines were rejected.

However in the response that ES sends the details of successfull or failed 
operations are included.

That's why I think a response relation would be useful.

The modification is not very hard to implement, but I think it could be usefull 
to treat failure during the Bulk operation.  here below a exemple of 
implementation :

 
{code:java}
// code 
if (!isSuccess(statusCode)) {
    ResponseBody responseBody = getResponse.body();
    try {
        final byte[] bodyBytes = responseBody.bytes();
        JsonNode responseJson = parseJsonResponse(new 
ByteArrayInputStream(bodyBytes));
        FlowFile fileResponse = session.create();
        fileResponse = session.write(fileResponse, new OutputStreamCallback() {
            @Override
            public void process(final OutputStream out) throws IOException {
                getLogger().debug(responseJson.toString());
                out.write(responseJson.toString().getBytes());
            }
        });
{code}
 

 

  was:
When Using the processor  PutElasticsearchHttpRecord,

Nifi send request to Elastic bulk interface. the Request include multiple lines.

If the request fails, we have no indications which of the lines were rejected.

However in the response that ES sends the details of successfull or failed 
operations are included.

That's why I think a response relation would be useful.

The modification is not very hard to implement, but I think it could be usefull 
to treat failure during the Bulk operation.  here below a exemple of 
implementation : 

 
{code:java}
// code 
if (isSuccess(statusCode)) {
    ResponseBody responseBody = getResponse.body();
    try {
        final byte[] bodyBytes = responseBody.bytes();
        JsonNode responseJson = parseJsonResponse(new 
ByteArrayInputStream(bodyBytes));
        FlowFile fileResponse = session.create();
        fileResponse = session.write(fileResponse, new OutputStreamCallback() {
            @Override
            public void process(final OutputStream out) throws IOException {
                getLogger().debug(responseJson.toString());
                out.write(responseJson.toString().getBytes());
            }
        });
{code}
 

 


> Processor PutElasticsearchHttpRecord should a relation Response
> ---------------------------------------------------------------
>
>                 Key: NIFI-5982
>                 URL: https://issues.apache.org/jira/browse/NIFI-5982
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>    Affects Versions: 1.5.0
>            Reporter: Abdou Bourakba
>            Priority: Minor
>
> When Using the processor  PutElasticsearchHttpRecord,
> Nifi send request to Elastic bulk interface. the Request include multiple 
> lines.
> If the request fails, we have no indications which of the lines were rejected.
> However in the response that ES sends the details of successfull or failed 
> operations are included.
> That's why I think a response relation would be useful.
> The modification is not very hard to implement, but I think it could be 
> usefull to treat failure during the Bulk operation.  here below a exemple of 
> implementation :
>  
> {code:java}
> // code 
> if (!isSuccess(statusCode)) {
>     ResponseBody responseBody = getResponse.body();
>     try {
>         final byte[] bodyBytes = responseBody.bytes();
>         JsonNode responseJson = parseJsonResponse(new 
> ByteArrayInputStream(bodyBytes));
>         FlowFile fileResponse = session.create();
>         fileResponse = session.write(fileResponse, new OutputStreamCallback() 
> {
>             @Override
>             public void process(final OutputStream out) throws IOException {
>                 getLogger().debug(responseJson.toString());
>                 out.write(responseJson.toString().getBytes());
>             }
>         });
> {code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to