https://github.com/cclient/nifi-email-bundle
nifi练习项目,聚合多flowfile的attribute,以单个邮件发放通知
https://github.com/cclient/nifi-email-bundle
Last synced: 8 months ago
JSON representation
nifi练习项目,聚合多flowfile的attribute,以单个邮件发放通知
- Host: GitHub
- URL: https://github.com/cclient/nifi-email-bundle
- Owner: cclient
- License: apache-2.0
- Created: 2021-02-28T10:11:58.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-28T13:10:53.000Z (over 5 years ago)
- Last Synced: 2025-01-16T22:20:02.626Z (over 1 year ago)
- Language: Java
- Homepage: https://www.cnblogs.com/zihunqingxin/p/14459954.html
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Nifi SendEmail Processor
================================
```orginal
flowfile0 mail0(flowfile0)
flowfile1 PutMail(1:1) mail1(flowfile1)
flowfile2 mail2(flowfile2)
```
```this
flowfile0
flowfile1 SendMail(n:1) mail(flowfile0,flowfile1,flowfile2)
flowfile2
```
### 需求
* nifi生态和自定义processor下通常有failure stream的处理,为了及时发现failure需统一发送通知邮件
* upstream 里会堆积多项flowfile,1:1发送邮件则通知过多,因此n:1 把多项flowfile合并在一个邮件里发送(只发送flowfile的attribute信息)
* 邮件内容为table,每列是一个attribute,attribule取并集,每行是一个flowfile的所有attribute
基于官方的[PutMail](https://github.com/apache/nifi/blob/a9db5a8cb7313005b4077b66ce10ef81d3055ee8/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java) 开发
可以组合多个官方processor实现该功能,例如在前置Processor完成拼接email msg内容,直接通过putMail发送邮件
通过简单定制实现也是为了熟悉nifi的开发/测试规范
邮件为html body如下
a0
a1
a2
a3
filename
path
uuid
entryDate
size
v0
v1
v2
v3
184775642434972.mockFlowFile
target
1bdaef1f-960b-48c5-a739-a881f92d1466
Thu May 21 15:37:00 CST 2020
v0
v1
v2
v3
184323287499017.mockFlowFile
target
45caab10-50c4-4727-ac42-bc345670cf85
Thu May 21 15:37:00 CST 2020
Thu Jan 01 08:00:00 CST 1970
### deploy
#### 1 compile
`mvn package -Dmaven.test.skip=true`
#### 2 upload to one of
```nifi
nifi.nar.library.directory=./lib
nifi.nar.library.directory.custom=./lib_custom
nifi.nar.library.autoload.directory=./extensions
nifi.nar.working.directory=./work/nar/
```
cp nifi-email-nar/target/nifi-email-nar-0.1.nar nifi/lib_custom/
#### 3 restart nifi if need
nifi/bin/nifi.sh restart