Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Nifi Custom processor not able to read the attributes from variable registry.

Highlighted

Nifi Custom processor not able to read the attributes from variable registry.

New Contributor

In Nifi custom processor configuring some attributes as expressions to read values from variable registry, but it is reading expression itself instead of reading its value.

Example Code as below.

protected static final PropertyDescriptor HOST = new PropertyDescriptor.Builder()
.name("Feed URL")
.description("Feed Service Host")
.required(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();

 

@Override
public void onTrigger(final ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {

final ComponentLog logger = getLogger();
try {
sessionFactoryReference.compareAndSet(null, sessionFactory);
String hostValue = context.getProperty(HOST).toString(); //
}
}

So from the above code if we print 'hostValue' its printing the expression as ${Feed-URL} instead of printing value of expression.

1 REPLY 1

Re: Nifi Custom processor not able to read the attributes from variable registry.

New Contributor

Issue got resolved, below piece of code did the magic.

 

context.getProperty(HOST).evaluateAttributeExpressions().getValue();

Don't have an account?
Coming from Hortonworks? Activate your account here