I have a string with constant value and I want to pass it to rename_to header while using MV gateway.
I have tried below code snippet and one by adding the variable in context and then using it with #basePath
@Value("${basePath:/home/}")
String basePath;
.enrichHeaders(h -> h
.headerExpression(RENAME_TO, "'${basePath}' + headers[file_remoteFile]")
.headerExpression(REMOTE_FILE, "headers[file_remoteFile]")
.header(REMOTE_DIRECTORY, "headers[file_remoteDirectory]"))
I am getting error on startup. How can I give basePath in my application.properties
@Value("${basePath:/home/}")
String basePath;
Means "inject '/home/' into variable basePath
if there is no basePath
property.
You can't use fields from the enclosing class like that in the SPeL expression, and you can't use property placeholders in SpEL there; you have to concatenate the strings in the java.
.headerExpression(RENAME_TO, "'" + this.basePath + "'" + " + headers[file_remoteFile]")