Apache Nifi 入门到精通(三)自定义processor

本文详细介绍了如何从头开始创建并使用Apache Nifi的自定义Processor。首先,创建了一个名为nifi-rest-bundle的Maven项目,并分为nifi-rest-nar和nifi-rest-processors两个模块。接着,通过服务配置注入Processor实现类。然后,实现了RestProcessor,包括参数配置、初始化以及REST请求处理逻辑。最后,打包NAR文件,将其放入Nifi的lib目录,启动Nifi以使用新Processor。
摘要由CSDN通过智能技术生成

目标:实现从restful接口读取到nifi

 

第一步:创建processor项目结构

创建maven项目

 项目名nifi-rest-bundle

 

完成创建项目:

修改 pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.nifi</groupId>
    <artifactId>nifi-nar-bundles</artifactId>
    <version>1.12.1</version>
  </parent>

  <groupId>com.lk.nifi.rest</groupId>
  <artifactId>nifi-rest-bundle</artifactId>
  <name>nifi-rest-bundle</name>

  <packaging>pom</packaging>



</project>

同上述步骤在nifi-rest-bundle中创建两个模块:nifi-rest-nar 和 nifi-rest-processors

注:示例中我删除了不必要的文件,如:测试文件目录等 

 nifi-rest-nar 模块中的pom 配置:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.lk.nifi.rest</groupId>
    <artifactId>nifi-rest-bundle</artifactId>
    <version>1.12.1</version>
  </parent>

  <artifactId>nifi-rest-nar</artifactId>
  <packaging>nar</packaging>
  <name>nifi-rest-nar</name>

  <dependencies>
    <dependency>
      <groupId>com.lk.nifi.rest</groupId>
      <artifactId>nifi-rest-processors</artifactId>
      <version>1.12.1</version>
    </dependency>
  </dependencies>

</project>

nifi-rest-processors 模块 的pom 配置:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

long-king

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值