Spring boot Spring云流转换表达式语法
我正在使用本地springclouddataflow服务器和shell来试验springcloudstream。我有过这样简单的例子Spring boot Spring云流转换表达式语法,spring-boot,spring-cloud-stream,spring-cloud-dataflow,Spring Boot,Spring Cloud Stream,Spring Cloud Dataflow,我正在使用本地springclouddataflow服务器和shell来试验springcloudstream。我有过这样简单的例子 dataflow:>stream create --name test --definition "time --trigger.time-unit=SECONDS | log" --deploy 工作正常,因为我每秒在日志中看到一条消息 2017-08-09 12:51:30,602 INFO -kafka-listener-1 log-sink:20
dataflow:>stream create --name test --definition "time --trigger.time-unit=SECONDS | log" --deploy
工作正常,因为我每秒在日志中看到一条消息
2017-08-09 12:51:30,602 INFO -kafka-listener-1 log-sink:202 - 08/09/17 12:51:30
2017-08-09 12:51:31,603 INFO -kafka-listener-1 log-sink:202 - 08/09/17 12:51:31
2017-08-09 12:51:32,605 INFO -kafka-listener-1 log-sink:202 - 08/09/17 12:51:32
.... more log msgs ....
现在我尝试扩展这个示例以插入一个变换。我希望每秒在日志中看到一次“hello world”,而不是时间,我不知道如何正确指定表达式
我试过这个:
dataflow:>stream create --name test --definition "time --trigger.time-unit=SECONDS | transform --transformer.expression='hello world' | log" --deploy
这(注意加上“#{}”):
但我在转换日志中继续得到一个错误:
Failed to convert property value of type 'java.lang.String'
to required type 'org.springframework.expression.Expression' for
property 'expression'; nested exception is
org.springframework.core.convert.ConverterNotFoundException: No converter
found capable of converting from type [java.lang.String] to type
[org.springframework.expression.Expression]
我已经阅读了(我觉得这没有什么帮助,因为这些示例都是Java代码)。我还看了一些春季云流的例子
我错过了什么
一旦“hello world”开始工作,我也想从本地Dataflow服务器的application.yml文件中回显一个属性;欢迎您的建议
更新:我遵循了1.3.0.M1里程碑的文档。这些应用程序都加载了
dataflow:>app import --uri http://bit-ly/Bacon-RELEASE-stream-applications-kafka-10-maven
正如文件所记载的那样。(注意,出于本文的目的,将bit.ly替换为bit.ly,因为StackOverflow不喜欢bit.ly URL。)当我在浏览器中直接点击bit.ly URL并下载文件时,我看到:
source.file=maven://org.springframework.cloud.stream.app:file-source-kafka-10:1.2.0.RELEASE
source.file.metadata=maven://org.springframework.cloud.stream.app:file-source-kafka-10:jar:metadata:1.2.0.RELEASE
source.ftp=maven://org.springframework.cloud.stream.app:ftp-source-kafka-10:1.2.0.RELEASE
....
下载1.3.0.M1应用程序应该使用什么URL?1.2.0应用程序似乎无法与1.3.0.M1服务器配合使用,这是一个问题吗?看起来您使用了一些旧版本的SCDF和所有现成的应用程序 所有应用程序在
转换中都有类似的功能:
@EnableBinding(Processor.class)
@EnableConfigurationProperties(TransformProcessorProperties.class)
public class TransformProcessorConfiguration {
其中,@EnableBinding
来自Spring Cloud Stream,具有:
@Configuration
@Import({ BindingServiceConfiguration.class, BindingBeansRegistrar.class, BinderFactoryConfiguration.class,
SpelExpressionConverterConfiguration.class })
@EnableIntegration
public @interface EnableBinding {
请注意SpelexPressionConverter配置
。正是这个函数负责将字符串转换为表达式
属性
因此,请确保您使用最新的Bacon
SCSt应用程序:看起来您使用了一些旧版本的SCDF和所有现成的应用程序
所有应用程序在转换中都有类似的功能:
@EnableBinding(Processor.class)
@EnableConfigurationProperties(TransformProcessorProperties.class)
public class TransformProcessorConfiguration {
其中,@EnableBinding
来自Spring Cloud Stream,具有:
@Configuration
@Import({ BindingServiceConfiguration.class, BindingBeansRegistrar.class, BinderFactoryConfiguration.class,
SpelExpressionConverterConfiguration.class })
@EnableIntegration
public @interface EnableBinding {
请注意SpelexPressionConverter配置
。正是这个函数负责将字符串转换为表达式
属性
因此,请确保使用最新的Bacon
SCSt应用程序:请参阅
要从shell中插入文字表达式,需要“hello”或“hello”。请参阅
要从shell中插入文字表达式,您需要\“'hello'”或''hello''。要从shell中插入文字表达式,您需要\''hello'\'
或''hello''
@GaryRussell,就是这样。我使用了''hello'
版本,效果很好。我真的想过并尝试过脱壳,但显然没有达到正确的咒语。如果你加上这个作为回答,我会接受的。对于像“?”这样的特殊字符,我只是反斜杠吗?要从shell中插入一个文本表达式,您需要\“'hello'\”
或''hello'
@GaryRussell,就是这样。我使用了''hello'
版本,效果很好。我真的想过并尝试过脱壳,但显然没有达到正确的咒语。如果你加上这个作为回答,我会接受的。对于像“?”这样的特殊字符,我只是反斜杠吗?要从shell中插入一个文本表达式,您需要\“'hello'\”
或''hello'
。要从shell中插入一个文本表达式,您需要\“'hello'\”
或“您好”
。我在过去一天左右阅读了所有文档,不知怎的错过了本节。非常感谢你!在过去的一天左右,我阅读了所有的文档,不知怎么的,我错过了这一节。非常感谢你!