Github user arpadboda commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/421#discussion_r227360200
  
    --- Diff: libminifi/include/capi/Plan.h ---
    @@ -93,11 +95,50 @@ class ExecutionPlan {
         next_ff_ = ptr;
       }
     
    +  static std::shared_ptr<core::Processor> createProcessor(const 
std::string &processor_name, const std::string &name);
    +
      protected:
    +  class FailureHandler {
    +   public:
    +    FailureHandler() {
    +      callback_ = nullptr;
    +    }
    +    void setCallback(void (*onerror_callback)(const flow_file_record*)) {
    +      callback_=onerror_callback;
    +    }
    +    void operator()(const processor_session* ps)
    +    {
    +      auto ses = static_cast<core::ProcessSession*>(ps->session);
    +
    +      auto ff = ses->get();
    +      if (ff == nullptr) {
    +        return;
    +      }
    +      auto claim = ff->getResourceClaim();
    +
    +      if (claim != nullptr && callback_ != nullptr) {
    +        // create a flow file.
    +        auto path = claim->getContentFullPath();
    +        auto ffr = create_ff_object_na(path.c_str(), path.length(), 
ff->getSize());
    +        ffr->attributes = ff->getAttributesPtr();
    +        ffr->ffp = ff.get();
    +        callback_(ffr);
    +      }
    +      // This deletes the content of the flowfile as ff gets out of scope
    +      // It's the users responsibility to copy all the data
    +      ses->remove(ff);
    +
    +    }
    +   private:
    +    void (*callback_)(const flow_file_record*);
    --- End diff --
    
    Done


---

Reply via email to