[英]Spring cloud data flow Httpclient
I have the following stream. 我有以下流。 Context of the problem
问题的背景
1. 1。
rabbit --password='******' --queues=springdataflow-q --virtual-host=springdataflow --host=172.24.172.184 --username=springdataflow | transform | httpclient --url-expression='http://172.20.24.47:8080/push' --http-method=POST --headers-expression={'Content-Type':'application/x-www-form-urlencoded'} --body-expression={arg1:payload} | log
2. 2。
I have spring boot running locally. 我在本地运行Spring Boot。
@RestController
public class HelloController {
@RequestMapping(value = "/push", method = RequestMethod.POST,produces = {MediaType.TEXT_PLAIN})
public String pushMessage(@RequestParam(value="arg1") String payload) {
System.out.println(payload);
return payload;
}
}
I would like to have the rabbit message come into httpclient
as value for the the 'arg1' parameter value to the post request. 我希望让
httpclient
消息作为post请求中'arg1'参数值的值进入httpclient
。 The intent being that message published on rabbit queue is consumed by a rest post point, the message being captured by SpEL payload. 目的是发布在兔子队列上的消息被剩余发布点消耗,该消息被SpEL有效负载捕获。
For this I am using the body-expression = {arg1:payload}
but this is not working, maybe syntactically wrong. 为此,我正在使用
body-expression = {arg1:payload}
但这不起作用,可能在语法上是错误的。
Any suggestions ? 有什么建议么 ?
The @RequestParam(value="arg1")
is really about request param, the part of the URL after ?
@RequestParam(value="arg1")
实际上是关于请求参数的,URL之后的部分?
, which is called query string
: https://en.wikipedia.org/wiki/Query_string . ,称为
query string
: https : //en.wikipedia.org/wiki/Query_string 。
So, if you really would like to have an arg1=payload
pair in the query string, you need to use a proper url-expression
: 因此,如果您确实想在查询字符串中使用
arg1=payload
对,则需要使用适当的url-expression
:
--url-expression='http://172.20.24.47:8080/push?arg1='+payload
This seems to work to pass strings as payloads. 这似乎可以将字符串作为有效载荷进行传递。 It seems that by default the payload becomes requestbody.
似乎默认情况下,有效负载将成为requestbody。 So on the rest service I made a change: @RequestMapping(value = "/pushbody", method = RequestMethod.POST,consumes = {MediaType.TEXT_PLAIN}) public String pushBody(@RequestBody String payload) { System.out.println(payload);
因此,在其余服务上,我进行了更改:@RequestMapping(value =“ / pushbody”,method = RequestMethod.POST,consumes = {MediaType.TEXT_PLAIN})public String pushBody(@RequestBody String payload){System.out.println(有效载荷); return payload;
返回有效载荷; }
}
And the stream that seems to work now is : rabbit --password='******' --queues=springdataflow-q1 --host=172.24.172.184 --virtual-host=springdataflow --username=springdataflow | 现在看来有效的流是:rabbit --password ='******'--queues = springdataflow-q1 --host = 172.24.172.184 --virtual-host = springdataflow --username = springdataflow | httpclient --http-method=POST --headers-expression={'Content-Type':'text/plain'} --url= http://172.20.24.47:8080/pushbody |
httpclient --http-method = POST --headers-expression = {'Content-Type':'text / plain'} --url = http://172.20.24.47:8080/pushbody | log
日志
I did try with inputType= text/plain suggestion both on httpclient and logsink and removing the consumes and produces on the rest service post method, but no luck there. 我确实尝试在httpclient和logsink上都使用inputType = text / plain建议,并删除了其余服务post方法上的消耗和产生,但是没有运气。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.