Я пытаюсь запустить пример кода дано в документации WSO2 Siddhi.
Я воспроизвел то, что там было дано.
@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);
На вкладке «Имитатор событий» я передал значения, указанные в примере, а именно: 154467847759 в поле метки времени и 5555555555554444 в номер кредитной карты (STRING).
Это ошибка, которая приходит.
[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)
Согласно ошибке, я думаю, что вы не подключены к publisher.url в определении потока CreditCardStream.
Перед моделированием событий убедитесь, что 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}]
Я все еще получаю эту ошибку. Приведенное выше сообщение журнала появляется, когда я запускаю приложение siddhi.
Согласно напечатанной ошибке, запрос, отправленный на https://secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType, возвращает ответ 500. Поскольку у вас нет источника http-ответ для приема 500 ответов, полезная нагрузка ответа будет удалена.
Поведение, которое вы наблюдаете, не может быть воспроизведено с нашей стороны. Учебник работает правильно, как показано.
Ниже приведена измененная версия учебного примера с фиктивной конечной точкой. Можешь попробовать.
@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='http://www.mocky.io/v2/5cee2fa1300000013a6e9961',method='POST', headers="'Content-Type:application/x-www-form-urlencoded'",
sink.id="cardTypeSink",
@map(type='keyvalue', @payload(CardNumber='{{creditCardNo}}')))
define stream CreditCardStream (creditCardNo string);
В логах написано, что подключение успешное - INFO {org.wso2.extension.siddhi.io.http.sink.HttpSink} - Http_Request_Response_Tutorial:@sink( type = "http-request", publisher.url = "secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType", method = "POST", headers = "'Content-Type:application/x-www-form-urlencoded'", sin.id = "cardTypeSink", @map( type = "keyvalue", @payload( CardNumber = "{{ CreditCardNo}}"))) определить поток CreditCardStream (строка CreditCardNo) успешно подключился к secure.ftipgw.com/ArgoFire/validate.asmx/GetCardType (закодировано)