-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIFI-12411: Update PublishAMQP to read AMQP headers value from FlowFile attributes and amq$headers
string
#8105
Conversation
a84db6e
to
8081da9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the proposed improvement @umarhussain15.
The general focus on the change makes sense, but there are some other stylistic recommendations I noted. It is helpful to improve the overall Processor implementation through the definition and reuse of static values for things like FlowFile attributes, so thanks for including those changes.
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/ConsumeAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
8081da9
to
0f18099
Compare
@umarhussain15 Can you please rebase and consider the feedback shared from @exceptionfactory ? Thanks |
0f18099
to
aad49a6
Compare
Hi @joewitt @exceptionfactory, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes applied in new commits
I have added one more change, which will allow users to set amqp processor's password via env variables. |
Thanks for calling out this particular change @umarhussain15. Given the scope of the current pull request, I recommend considering that change separately. In general, sensitive properties such as passwords do not support reading from environment variables. The reason is that environment variables are also accessible through Expression Language, so they are not necessarily secure. The use case is still supported through Parameter Contexts and Parameter Providers, where the Environment Variable Parameter Provider can be used. This is an additional layer of indirection, but it follows the general convention for other sensitive properties. |
Thanks for the explanation, @exceptionfactory. I will revert the change here then. |
8452c49
to
b8e6ab6
Compare
Reverted the AbstractAMQPProcessor change to support expression language in password field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up @umarhussain15. Please note, the Checkstyle rules were recently updated to include consistency checking for whitespace, so the latest static analysis build noted these issues:
Warning: src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java:[115,38] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Warning: src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java:[307,76] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Warning: src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java:[314,76] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Warning: src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java:[316,76] (whitespace) WhitespaceAfter: ',' is not followed by whitespace.
Warning: src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java:[380,68] (whitespace) WhitespaceAround: '{' is not preceded with whitespace.
Warning: src/main/java/org/apache/nifi/amqp/processors/ConsumeAMQP.java:[349,69] (whitespace) WhitespaceAround: '{' is not preceded with whitespace.
Checkstyle reported issues fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@umarhussain15 This looks close to completion. There is one minor merge conflict right now related to logging that should be easy to address in a rebase and force push. The only other suggested change is to use Map.of()
instead of anonymous HashMaps in the test methods.
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...ndle/nifi-amqp-processors/src/test/java/org/apache/nifi/amqp/processors/PublishAMQPTest.java
Outdated
Show resolved
Hide resolved
...ndle/nifi-amqp-processors/src/test/java/org/apache/nifi/amqp/processors/PublishAMQPTest.java
Outdated
Show resolved
Hide resolved
...ndle/nifi-amqp-processors/src/test/java/org/apache/nifi/amqp/processors/PublishAMQPTest.java
Outdated
Show resolved
Hide resolved
…le attributes and `amq$headers` string Processor can now also create message headers using attributes matching the given Regex property. The name of attribute is used as header key. In addition to that it can read values from two sources i.e. attributes matching Regex and the headers present in `amq$headers` string. In case of key duplication in both sources the precedence property decide which value will be used. Signed-off-by: Umar Hussain <umarhussain.work@gmail.com>
e7f50d0
to
c3e8471
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @umarhussain15. On further review, the implementation and property names raise a few more questions, particular in terms of the Precedence
property. If you can address the syntax issues, that would be helpful, and consider whether the Precedence
property is necessary.
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
...p-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java
Outdated
Show resolved
Hide resolved
apply other suggestions from PR for using enum directly for headers source etc.
Hi @exceptionfactory, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working through the feedback and making adjustments @umarhussain15, the latest version looks ready to go. +1 merging
Summary
NIFI-12411
Processor can now also create message headers using attributes matching the given Regex property. The name of the attribute is used as header key. In addition to that it can read values from two sources i.e. attributes matching Regex and the headers present in
amq$headers
string. In case of key duplication in both sources, the precedence property decide which value will be used.AMQP attributes keys are now set as constants strings and reused where needed.
Added
onScheduled
to PublishAMQP and ConsumeAMQP to read all properties which don't change during running state.Test cases added for
PublishAMQP
headers source changes.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation