Member since
07-29-2020
574
Posts
323
Kudos Received
176
Solutions
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1976 | 12-20-2024 05:49 AM | |
2202 | 12-19-2024 08:33 PM | |
2022 | 12-19-2024 06:48 AM | |
1326 | 12-17-2024 12:56 PM | |
1903 | 12-16-2024 04:38 AM |
07-20-2023
06:44 AM
1 Kudo
Hi @ShaniKumar , Can you please identify clearly with the issue is to help you better? Basically the InvokeHTTP processors allows you to use dynamic invocation using Nifi Expression Language (EL). You can set a flowfile attribute with the intended url before calling the InvokeHttp processor , for example: you can use UpdateAttribute to set the url to attribute name "UrlAttr" and then reference this attribute in the InvokeHttp "Remote URL" property value as ${UrlAttr}. Other InvokeHttp properties allows to use EL to set the value dynamically and so on as long as the property allows it. Hope that helps. Thanks
... View more
07-19-2023
01:08 PM
Hi @Dataengineer1 , This has been asked before , please refer to : https://community.cloudera.com/t5/Support-Questions/NIFI-Is-it-possible-to-make-a-x-www-form-urlencoded-POST/m-p/339398 Thanks
... View more
07-12-2023
08:38 AM
Definitely upgrade to the latest NiFI which is 1.22.
... View more
06-16-2023
11:26 AM
You have to create a separate case statement for each column you are trying to update similar to what is done for the shipment number.
... View more
06-16-2023
06:09 AM
Hi, The path you specified seems to be correct according to the XML you provided. Since you did not provide the full XML I was only able to test it on the following: <?xml version="1.0" encoding="UTF-8"?>
<SalesOrder>
<MessageProcessingInformation>
<SendingSystemID>SMS_0175</SendingSystemID>
</MessageProcessingInformation>
<Header>
<SalesDocumentType>YPO0</SalesDocumentType>
<SalesOrganization>7002</SalesOrganization>
<DistributionChannel>00</DistributionChannel>
<RequestedDeliveryDate>2023-06-15</RequestedDeliveryDate>
<CustomerPurchaseOrderDate>2023-06-15</CustomerPurchaseOrderDate>
<Incoterms1>EXW</Incoterms1>
<Incoterms2>Ex Works</Incoterms2>
<PaymentTerms>E007</PaymentTerms>
<CustomerPurchaseOrderNumber>990831 </CustomerPurchaseOrderNumber>
<ReferenceDocumentNumber>SI-000000614</ReferenceDocumentNumber>
<ServicesRenderedDate>2023-06-15</ServicesRenderedDate>
<LogisticData>
<SourceReferenceDocumentNumber>SI-000000614</SourceReferenceDocumentNumber>
<SourceSalesOrderNumber>SO-000050562</SourceSalesOrderNumber>
</LogisticData>
</Header>
</SalesOrder> and I was able to get the ReferenceDocumentNumber using the Path: /SalesOrder/Header/ReferenceDocumentNumber Notice I had to remove the following line because I was getting Parsing Error: <ns1:SalesOrderMessages mlns:ns1="http://corpintra.net/pi/CBFC_GLOBAL_SAP_APPL/SalesOrder" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> What are you seeing exactly? Are you seeing an error or the value is not populated in the FileName attribute ? Can you please provide more info on that? Thanks
... View more
06-14-2023
02:26 PM
This could possibly be achieved via a InvokeScriptedProcessor but I would need to know the source and what the expected output would be. For example, taking what you posted and you want to filter on code=6 and code=8 and only have the values of "other" as individual FlowFiles, then something like this Groovy based code could achive that import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import java.nio.charset.StandardCharsets
import org.apache.commons.io.IOUtils
class GroovyProcessor implements Processor {
PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder()
.name("BATCH_SIZE")
.displayName("Batch Size")
.description("The number of incoming FlowFiles to process in a single execution of this processor.")
.required(true)
.defaultValue("1000")
.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
.build()
PropertyDescriptor FILTER_CODES = new PropertyDescriptor.Builder()
.name("FILTER_CODES")
.displayName("Filter Codes")
.description("Codes to Filter On")
.required(true)
.defaultValue("6,8")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build()
Relationship REL_SUCCESS = new Relationship.Builder()
.name("success")
.description('FlowFiles that were successfully processed are routed here')
.build()
Relationship REL_FAILURE = new Relationship.Builder()
.name("failure")
.description('FlowFiles that were not successfully processed are routed here')
.build()
ComponentLog log
void initialize(ProcessorInitializationContext context) { log = context.logger }
Set<Relationship> getRelationships() { return [REL_FAILURE, REL_SUCCESS] as Set }
Collection<ValidationResult> validate(ValidationContext context) { null }
PropertyDescriptor getPropertyDescriptor(String name) { null }
void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { }
List<PropertyDescriptor> getPropertyDescriptors() { Collections.unmodifiableList([BATCH_SIZE, FILTER_CODES]) as List<PropertyDescriptor> }
String getIdentifier() { null }
JsonSlurper jsonSlurper = new JsonSlurper()
JsonOutput jsonOutput = new JsonOutput()
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
ProcessSession session = sessionFactory.createSession()
try {
List<FlowFile> flowFiles = session.get(context.getProperty(BATCH_SIZE).asInteger())
if (!flowFiles) return
String filterCodesString = context.getProperty(FILTER_CODES).getValue()
List<Integer> filterCodes = filterCodesString.split(",").findAll { it.trim().matches("\\d+") }.collect { it as Integer }
flowFiles.each { flowFile ->
Map customAttributes = [ "mime.type": "application/json" ]
session.read(flowFile, { inputStream ->
inputStream.eachLine { line ->
if (line?.trim()) {
Map dataMap = jsonSlurper.parseText(line)
if (filterCodes.contains(dataMap.code.toInteger())) {
FlowFile newFlowFile = session.create()
newFlowFile = session.write(newFlowFile,
{
outputStream -> outputStream.write(jsonOutput.toJson(dataMap.other).getBytes(StandardCharsets.UTF_8))
} as OutputStreamCallback)
newFlowFile = session.putAllAttributes(newFlowFile, customAttributes)
session.transfer(newFlowFile, REL_SUCCESS)
}
}
}
} as InputStreamCallback)
session.remove(flowFile)
}
session.commit()
} catch (final Throwable t) {
log.error('{} failed to process due to {}; rolling back session', [this, t] as Object[])
session.rollback(true)
throw t
}
}
}
processor = new GroovyProcessor()
... View more
06-13-2023
06:47 AM
1 Kudo
Hi, I think what you need is the GetFile processor and not FetchFile. In the Fetch File you have to specify the exact file path and name that you want to fetch and you can't use wild card. However in the Get File you specify the path in the "Input Directory" then you can use Regex in the "File Filter" property to capture files with certain pattern. In your case the search pattern in Regex will be something like ".*xyz.*\.txt" You need to watch for other Properties like "Keep Source File" which decide what to do with the file after its picked up. If you want to loop indefinitely then "False" would be the right value. Once the file is picked up you can save it somewhere else using PutFile processor. The "Recurse Subdirectories" let you decide wither you want to search root folder only or all folder levels. If that helps please accept solution. Thanks
... View more
06-07-2023
01:58 AM
This worked. Thanks.
... View more
05-26-2023
08:40 AM
Thank You @MattWho @SAMSAL for your wonderful suggestions. I achieved solution using JolttransformJSON processor, where i used below jolt specification [{ "operation": "default", "spec": { "*": { "error": "${putdatabaserecord.error}" } } }] Thanks again for your thought provoking answers..
... View more
05-26-2023
07:38 AM
1 Kudo
Hi, The request Body has to be provided as flowfile to the InvokeHttp Processor per the processor description: You can use an upstream processor to the InvokeHttp like ReplaceText processor to generate the request body a follows: To send incoming flowfile content as Request Body , make sure the following property of the invokehttp processor is set to true (default): To make sure you are always getting a response no matter if its successful or not make sure to set the following invokehttp processor to true (default false): If that helps please accept solution. Thanks
... View more