Hi Caron,
You should create a new AsynchronousHttpClient for each new request (The async
http client can't handle concurrent request atm).
So above client.fetch(..) you should add
AsynchronousHttpClient client = new AsynchronousHttpClient();
HTH
Roger Schildmeijer
Ps. Don't hesitate to contact us again if experience other problems. irc
(#deft, freenode) or here on the mailing list. Ds.
On Nov 7, 2011, at 11:19 PM, Caron, Maxime wrote:
> Hi deft developer,
>
> [java] Exception in thread "I/O-LOOP1" java.lang.NullPointerException
> [java] at
> org.apache.deft.web.http.client.AsynchronousHttpClient.cancelTimeout(AsynchronousHttpClient.java:230)
> [java] at
> org.apache.deft.web.http.client.AsynchronousHttpClient.onHeaders(AsynchronousHttpClient.java:314)
> [java] at
> org.apache.deft.web.http.client.AsynchronousHttpClient.access$500(AsynchronousHttpClient.java:56)
> [java] at
> org.apache.deft.web.http.client.AsynchronousHttpClient$4.onSuccess(AsynchronousHttpClient.java:306)
> [java] at
> org.apache.deft.web.http.client.AsynchronousHttpClient$4.onSuccess(AsynchronousHttpClient.java:304)
> [java] at
> org.apache.deft.io.AsynchronousSocket.invokeReadSuccessfulCallback(AsynchronousSocket.java:302)
> [java] at
> org.apache.deft.io.AsynchronousSocket.checkReadState(AsynchronousSocket.java:269)
> [java] at
> org.apache.deft.io.AsynchronousSocket.handleRead(AsynchronousSocket.java:220)
> [java] at org.apache.deft.io.IOLoop.start(IOLoop.java:111)
>
> My code is a follow
> public void process(TradeExecution ex){
> System.out.println("sent execution confirmation for:" +
> ex.tradeMatchNumber);
> if (ex!= null){
> sendResponse(ex.buyerBrokerUrl(),ex.buyerResponse());
> sendResponse(ex.sellerBrokerUrl(),ex.sellerResponse());
> }
> }
>
> private void sendResponse(String broker, String response) {
> Request request = new Request(broker, HttpVerb.POST);
> request.setBody(response);
> request.setContentType(ContentType.APPLICATION_FORM_URLENCODED);
> client.fetch(request, new AsyncResult<Response>() {
> @Override
> public void onSuccess(final Response response) {
> if (response.getBody().contains("Accept")){
> System.out.println("server accepted execution confirmation");
> }
> }
> @Override
> public void onFailure(final Throwable caught) {
> }
> });
> }
>
> Any idea?
>
> Maxime Caron
> Morgan Stanley | Enterprise Infrastructure
> 700 Rue Wellington | Floor 04
> Montreal, QC H3C 3S4
> Phone: +1 514 876-5654
> [email protected]<mailto:[email protected]>
>
>
> --------------------------------------------------------------------------
> NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions
> or views contained herein are not intended to be, and do not constitute,
> advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform
> and Consumer Protection Act. If you have received this communication in
> error, please destroy all electronic and paper copies and notify the sender
> immediately. Mistransmission is not intended to waive confidentiality or
> privilege. Morgan Stanley reserves the right, to the extent permitted under
> applicable law, to monitor electronic communications. This message is subject
> to terms available at the following link:
> http://www.morganstanley.com/disclaimers. If you cannot access these links,
> please notify us by reply message and we will send the contents to you. By
> messaging with Morgan Stanley you consent to the foregoing.