我正在尝试将带有“order_id”键的标头和基于有效负载中属性的值添加到我的消息中。然后我将结果发送到日志接收器,我可以在标头处理器之后检查标头。这是流:
stream create --name add-header-to-message-stream
--definition
":aptly-named-destination
> add-order_id-header: header-enricher
--header.enricher.headers='order_id=payload.order.id \\n fizz=\"buzz\"'
| log
--log.expression=headers"
当我拖尾日志接收器时,我在标题图中看不到“order_id”或“fizz”的键。我能够部署流并通过管道运行数据而没有错误。如何在邮件中添加标题?
答案 0 :(得分:3)
这对我来说很好,但只有一个标题......
dataflow:>stream create foo --definition "time --fixedDelay=5 |
header-enricher --headers='foo=payload.substring(0, 1)' |
log --expression=#root " --deploy
结果
2017-06-21 08:28:38.459 INFO 70268 --- [-enricher.foo-1] log-sink:GenericMessage [payload = 06/21/17 08:28:38,headers = {amqp_receivedDeliveryMode = PERSISTENT,amqp_receivedRoutingKey = foo.header-enricher,amqp_receivedExchange = foo.header-enricher,amqp_deliveryTag = 1, foo = 0 ,amqp_consumerQueue = foo.header-enricher.foo,amqp_redelivered = false,id = 302f1d5b -ba90
我被告知这个...
--headers='foo=payload.substring(0, 1) \n bar=payload.substring(1,2)'
......或者......
--headers='foo=payload.substring(0, 1) \u000a bar=payload.substring(1,2)'
应该可以工作,但我得到一个解析错误......
Cannot find terminating ' for string time --fixedDelay=5 | header-enricher --headers='foo=payload.substring(0, 1)
bar=payload.substring(1,2)' | log --expression=#root
...我正在联系shell / deployer开发者,如果我有,我会提供更新。
我测试了一个文字值(单头)...
dataflow:>stream create foo --definition "time --fixedDelay=5 |
header-enricher --headers='foo=\"bar\"' |
log --expression=#root " --deploy
2017-06-21 08:38:17.684 INFO 70916 --- [-enricher.foo-1] log-sink:GenericMessage [payload = 06/21/17 08:38:17,headers = {amqp_receivedDeliveryMode = PERSISTENT,amqp_receivedRoutingKey = foo.header-enricher,amqp_receivedExchange = foo.header-enricher,amqp_deliveryTag = 8, foo = bar ,amqp_consumerQueue = foo.header-enricher.foo,amqp_redelivered = false,id = a92f4908 -af13-53aa-205d-e25e204d04a3,amqp_consumerTag = amq.ctag-X51lhhRWBbEDVSyzp3rGmg,contentType = text / plain,timestamp = 1498048697684}]