You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by camel <jj...@gmail.com> on 2013/08/05 22:12:58 UTC

how to create HttpEntityEnclosingRequest with HttpAsyncContentProducer entity ?

HttpAsyncClient httpClient ; in debuger it is
org.apache.http.impl.nio.client.DefaultHttpAsyncClient, (so looks good)
httpClient.execute(HttpRequestBase, callback);

httpRequestBase was created as 
HttpRequestBase httpReq = null;
        httpReq = doPost ? new HttpPost(targetUrl) : new HttpGet(targetUrl);

if (doPost) {
    ((HttpPost) httpReq).setEntity(new UrlEncodedFormEntity(nvps));
}

later it results in executing non async code in:

    public BasicAsyncRequestProducer(final HttpHost target, final
HttpRequest request) {
        if (target == null) {
            throw new IllegalArgumentException("HTTP host may not be null");
        }
        if (request == null) {
            throw new IllegalArgumentException("HTTP request may not be
null");
        }
        this.target = target;
        this.request = request;
        if (request instanceof HttpEntityEnclosingRequest) {
            HttpEntity entity = ((HttpEntityEnclosingRequest)
request).getEntity();
            if (entity != null) {
                if (entity instanceof HttpAsyncContentProducer) {
                    this.producer = (HttpAsyncContentProducer) entity;  //
------> this is executed
                } else {
                    this.producer = new EntityAsyncContentProducer(entity);
// this is not executed, how to make it execute??
                }
            } else {
                this.producer = null;
            }
        } else {
            this.producer = null;
        }
    }

How should I create HttpRequestBase to later trigger executing async io ?

Now requests are send 2 by 2 - when first 2 sent requests get response, next
two are sent, other requests are possibly queued, sending isn't blocking,
but requests aren't really sent parallelly but they seem to be queued.

How should I fix it ?



--
View this message in context: http://cxf.547215.n5.nabble.com/how-to-create-HttpEntityEnclosingRequest-with-HttpAsyncContentProducer-entity-tp5731958.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: how to create HttpEntityEnclosingRequest with HttpAsyncContentProducer entity ?

Posted by camel <jj...@gmail.com>.
thx for notice,
I posted here
http://httpcomponents.10934.n7.nabble.com/how-to-create-HttpEntityEnclosingRequest-with-HttpAsyncContentProducer-entity-td20874.html



--
View this message in context: http://cxf.547215.n5.nabble.com/how-to-create-HttpEntityEnclosingRequest-with-HttpAsyncContentProducer-entity-tp5731958p5731997.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: how to create HttpEntityEnclosingRequest with HttpAsyncContentProducer entity ?

Posted by Daniel Kulp <dk...@apache.org>.
I believe you want to send this to:

httpclient-users@hc.apache.org

as this is pertaining to the Http components stuff and not CXF.

Dan



On Aug 5, 2013, at 4:16 PM, camel <jj...@gmail.com> wrote:

> sorry, I am mistaken
> 
>                if (entity instanceof HttpAsyncContentProducer) {
>                    this.producer = (HttpAsyncContentProducer) entity; -->
> this is not executed
>                } else {
>                    this.producer = new EntityAsyncContentProducer(entity); 
> ---> this is executed
>                }
> 
> /**
> * Basic implementation of {@link HttpAsyncContentProducer} that relies on
> * inefficient and potentially blocking I/O operation redirection through
> * {@link Channels#newChannel(java.io.InputStream)}.
> *
> * @since 4.2
> */
> @NotThreadSafe
> public class EntityAsyncContentProducer implements HttpAsyncContentProducer
> {
> 
> 
> ant possibly this is why my code isn't truly asynchronous,
> How should I fix it ?
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/how-to-create-HttpEntityEnclosingRequest-with-HttpAsyncContentProducer-entity-tp5731958p5731968.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: how to create HttpEntityEnclosingRequest with HttpAsyncContentProducer entity ?

Posted by camel <jj...@gmail.com>.
sorry, I am mistaken

                if (entity instanceof HttpAsyncContentProducer) {
                    this.producer = (HttpAsyncContentProducer) entity; -->
this is not executed
                } else {
                    this.producer = new EntityAsyncContentProducer(entity); 
---> this is executed
                }

/**
 * Basic implementation of {@link HttpAsyncContentProducer} that relies on
 * inefficient and potentially blocking I/O operation redirection through
 * {@link Channels#newChannel(java.io.InputStream)}.
 *
 * @since 4.2
 */
@NotThreadSafe
public class EntityAsyncContentProducer implements HttpAsyncContentProducer
{


ant possibly this is why my code isn't truly asynchronous,
How should I fix it ?



--
View this message in context: http://cxf.547215.n5.nabble.com/how-to-create-HttpEntityEnclosingRequest-with-HttpAsyncContentProducer-entity-tp5731958p5731968.html
Sent from the cxf-user mailing list archive at Nabble.com.