无法在Siddhi中执行同步请求响应示例

时间:2019-05-22 09:45:03

标签: siddhi sendasynchronousrequest wso2sp

我正在尝试运行WSO2 Siddhi文档中的示例代码given

我已经复制了那里给出的内容。

@App:name("Http_Request_Response_Tutorial")
@App:description("This app demonstrate the usage of http request sink and http response source")

@source(type='http-response' ,sink.id='cardTypeSink',
@map(type='xml', namespaces = "xmlns=http://localhost/SmartPayments/",
@attributes(creditCardNo = 'trp:creditCardNo',creditCardType = ".")))
@sink(type='log')
define stream EnrichedCreditCardStream (creditCardNo string,creditCardType string);

@sink(type='http-request',publisher.url='https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType',method='POST', headers="'Content-Type:application/x-www-form-urlencoded'",
sink.id="cardTypeSink",
@map(type='keyvalue', @payload(CardNumber='{{creditCardNo}}')))
define stream CreditCardStream (creditCardNo string);

在“事件模拟器”选项卡中,我传递了示例中给出的值:在timestamp字段中为154467847759,在creditCardNo(STRING)中为5555555555554444。

这是即将到来的错误。

[2019-05-22_14-59-14_632] ERROR {org.wso2.extension.siddhi.io.http.source.HttpResponseMessageListener} - No source of type 'http-response' for status code '500' has been defined. Hence dropping the response message. (Encoded) 

2 个答案:

答案 0 :(得分:0)

根据该错误,我认为您未连接到CreditCardStream的流定义中的Publisher.url。

在模拟事件之前,请确保CreditCardStream已连接到https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType

如果连接成功,您将获得如下日志。

[2019-05-23 12:19:36,713]  INFO {org.wso2.extension.siddhi.io.http.sink.HttpSink} - Http_Request_Response_Tutorial:@sink( type = "http-request", publisher.url = "https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType", method = "POST", headers = "'Content-Type:application/x-www-form-urlencoded'", sink.id = "cardTypeSink", @map( type = "keyvalue", @payload( CardNumber = "{{creditCardNo}}")))define stream CreditCardStream (creditCardNo string) has successfully connected to https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType
[2019-05-23 12:19:55,597]  INFO {org.wso2.siddhi.core.stream.output.sink.LogSink} - Http_Request_Response_Tutorial : EnrichedCreditCardStream : [Event{timestamp=1558594195597, data=[5555555544444, ], isExpired=false}]

答案 1 :(得分:0)

根据打印的错误,发送到https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType的请求将返回500响应。 由于您没有 http-response 来源来接受500个响应,因此将删除响应有效负载。

从我们的角度来看,您观察到的行为是不可复制的。该教程可以正常运行。

下面是带有虚拟端点的教程示例的修订版。你可以试试看。

 def bowling(p1,p2,p3,p4,p5):
        x=1
        while x<6:
            print(px.get('role'))