Skip to content
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-11609 Support Request-Response pattern in MQTT5 Processors #7352

Closed
wants to merge 1 commit into from

Conversation

nandorsoma
Copy link
Contributor

Summary

NIFI-11609

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 11
    • JDK 17

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

processedRecords.getAndIncrement();
}
} catch (SchemaNotFoundException | MalformedRecordException e) {
throw new ProcessException("An error happened during creating components for serialization.", e);
}
}

private String extractRecordValue(Record record, RecordPath recordPath) {
final Optional<FieldValue> fv = recordPath.evaluate(record).getSelectedFields().findFirst();
if (fv.isPresent()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit misleading, because FieldValue is present even when there is no result with a given record path. This makes me wonder that is it a valid scenario when fv is empty.

Comment on lines +211 to +213
PROP_RESPONSE_TOPIC,
PROP_CORRELATION_DATA,
PROP_CORRELATION_DATA_IS_RECORD_PATH,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nandorsoma Thanks for adding this new feature in the MQTT processors!

The functionality looks good, however the configuration of the new properties is not really straightforward. E.g. when sending the response to a request, the response topic (contained in the original request) needs to be set in Topic, not Response Topic (Response Topic is relevant for request messages, not responses). Also, the new properties may be confusing in the "normal" (non request/response) mode, so in most of the cases.

That's why I would suggest to document the request/response scenarios in the additional details page.
Also, introducing Messaging Type (or Messaging Pattern) property in PublishMQTT seems useful for me with the following allowable values:

  • Standalone: default/current logic (no Correlation Data or Response Topic displayed)
  • Request: sending a request message and expecting a response to it (Correlation Data and Response Topic displayed)
  • Response: sending a response message to a received request (Correlation Data is displayed, but Response Topic is not)

The role/origin of Correlation Data is a bit different in the last 2 cases. For requests, it is the message sender's responsibility to generate a unique correlation data. For responses, the message sender has to echo the received correlation data back. It can be mentioned in the property description or the additional details page.

@nandorsoma
Copy link
Contributor Author

Closing as the proposed solution with the extra fields is inconvenient. We need to find a generic way to specify raw value or record path in the same field.

@nandorsoma nandorsoma closed this Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants