Hello,
We are using CamelFileSink connector to read the messages from Kafka and dump
into file but we want each messages to be written in next line in file. We have
been trying to use appendChars option with double slash \n but it doesn't work.
Here is our file sink url :
file:/user/app/folder?appendChars=\n&autoCreate=true&fileExist=Append&fileName=messages-${date:now:yyyyMMdd}.txt&forceWrites=true&charset=utf-8
Here is what the error we get :
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve
endpoint:
file:/user/app/folder?appendChars=\n&autoCreate=true&fileExist=Append&fileName=messages-${date:now:yyyyMMdd}.txt&forceWrites=true&charset=utf-8
due to: Illegal character in query at index 34:
file:/user/app/folder?appendChars=\n&autoCreate=true&fileExist=Append&fileName=messages-$%7Bdate:now:yyyyMMdd%7D.txt&forceWrites=true&charset=utf-8\n\tat
org.apache.camel.support.EndpointHelper.normalizeEndpointUri(EndpointHelper.java:156)\n\tat
org.apache.camel.support.NormalizedUri.newNormalizedUri(NormalizedUri.java:46)\n\tat
We have even tried to define properties instead of using file sink uri and the
result is same. It gives us the same error.
Here is the error messages after defining the properties :
\nCaused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve
endpoint:
file:/user/app/folder?appendChars=\n&autoCreate=true&charset=UTF-8&fileExist=Append&fileName=messages-${date:now:yyyyMMdd}.txt&forceWrites=true
due to: Illegal character in query at index 34:
file:/user/app/folder?appendChars=\n&autoCreate=true&charset=UTF-8&fileExist=Append&fileName=messages-$%7Bdate:now:yyyyMMdd%7D.txt&forceWrites=true\n\tat
Here is our full connect config :
{
"name": "camel-file-sink-connector",
"connector.class":
"org.apache.camel.kafkaconnector.file.CamelFileSinkConnector",
"tasks.max": "1",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter",
"topics": "camel-file-sink-kafka-topic",
"camel.sink.contentLogLevel": "DEBUG",
"camel.idempotency.enabled": "false",
"camel.sink.path.directoryName": "/user/app/folder",
"camel.sink.endpoint.charset": "UTF-8",
"camel.sink.endpoint.fileName": "messages-${date:now:yyyyMMdd}.txt",
"camel.sink.endpoint.appendChars": "\n",
"camel.sink.endpoint.fileExist": "Append",
"camel.sink.endpoint.forceWrites": "true",
"camel.sink.endpoint.autoCreate": "true"
}
Kindly advise how to use \n in appendChars property of CamelFileSink Connector.
Thank you,
SVB Confidential
If you recently applied for credit or we are requesting additional information
to process your credit request: Important disclosures for Equal Credit
Opportunity Act and USA PATRIOT Act, please click
here<http://www.svb.com/equal-credit-opportunity-act-disclosures/>.