You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by bu...@apache.org on 2006/03/12 20:24:38 UTC

DO NOT REPLY [Bug 38943] New: - missing notification API for http-async

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943

           Summary: missing notification API for http-async
           Product: HttpClient
           Version: 4.0
          Platform: Other
               URL: http://wiki.apache.org/jakarta-
                    httpclient/UseCases/SingleAsyncRequestNotify
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HttpCommon
        AssignedTo: httpclient-dev@jakarta.apache.org
        ReportedBy: http-async@dubioso.net


Asynchronous HTTP communication doesn't make much sense without
the ability to be notified as responses become available.
Define a notification/callback API for this purpose.

patch follows,
  Roland

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943


http-async@dubioso.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #17877|0                           |1
        is obsolete|                            |




------- Additional Comments From http-async@dubioso.net  2006-03-23 14:50 -------
Created an attachment (id=17951)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=17951&action=view)
patch, take 2

This addresses most of the concerns that were raised:
- new JavaDoc and parameter name for HttpNotificationHandler.notifyResponse
- only one boolean in public SimpleHttpHandle.provideProblem
  (there now is a private internalProvideProblem)
- renamed NotifedAsyncGet to RoutingAsyncGet
- new NotifiedAsyncGet with only one service thread
  (and without checks that should go into test cases)

I've left the notification_handler attribute in AbstractHttpHandle
as final, mainly because I don't know how to prioritize an automated
call to setNotificationHandler by the Spring framework against a
notification handler set by the application in the request specific
HttpContext, or the default context. Let's revisit this when we have
code that would actually use the Spring framework to instantiate the
notification handler.

The patch has the usual problems with the @version lines in 4 classes.

cheers,
  Roland


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943


http-async@dubioso.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|httpclient-                 |http-async@dubioso.net
                   |dev@jakarta.apache.org      |
             Status|NEW                         |ASSIGNED




------- Additional Comments From http-async@dubioso.net  2006-03-12 19:32 -------
Created an attachment (id=17877)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=17877&action=view)
patch, take 1

This patch fails to apply in 4 files, again because of the @version
line in the class comment. To apply the patch, change that line to:

 * @version $Revision$ $Date$

in the following source files:

trunk/http-async/src/java/org/apache/http/async/AsyncHttpProcessor.java
trunk/http-async/src/java/org/apache/http/async/impl/SimpleHttpHandle.java
trunk/http-async/src/java/org/apache/http/async/impl/SimpleHttpDispatcher.java
trunk/http-async/src/java/org/apache/http/async/AbstractHttpHandle.java

This time, I've added several empty JavaDoc lines to the class comments,
so that the @version line will not be in the patch context in the future.

When reviewing this patch, please give the interface and example special
scrutiny. Currently, the callback handler is passed in the HttpContext,
so it can be changed on a per-request basis if needed.

This patch does not add logging. I'll do that in a separate step
once the notification interface is agreed upon and committed.

cheers,
  Roland

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943


olegk@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |httpclient-
                   |                            |dev@jakarta.apache.org




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943





------- Additional Comments From olegk@apache.org  2006-03-30 16:03 -------
+1 to checking the patch in

Oleg

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943


http-async@dubioso.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #17951|0                           |1
        is obsolete|                            |




------- Additional Comments From http-async@dubioso.net  2006-03-23 19:43 -------
Created an attachment (id=17954)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=17954&action=view)
patch, take 3

- NotifiedAsyncGet now self-contained and simplified
- RoutingAsyncGet and NotifiedServiceThread moved to contrib,
  but kept as separate classes

I'll address (1) on the mailing list.

cheers,
  Roland


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943





------- Additional Comments From http-async@dubioso.net  2006-03-30 15:58 -------
Any more comments on this one? If not, I'll make
this the subject of my first attempt at a commit
sometime this weekend.

cheers,
  Roland

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943


http-async@dubioso.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From http-async@dubioso.net  2006-04-10 19:06 -------
take 3 committed

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: [Bug 38943] - missing notification API for http-async

Posted by Roland Weber <ht...@dubioso.net>.
Hi Oleg,

> http://issues.apache.org/bugzilla/show_bug.cgi?id=38943
> ------- Additional Comments From olegk@apache.org  2006-03-23 16:43 -------
> (1) OK. Now I know what I was missing. So, essentially you want the consumer of
> the notification interface simply to queue the responses up for processing
> rather than to process them.

Yes, exactly. That was my working assumption right from the start.
I would like to keep this restriction (and enforce it rigorously)
until I have completed some production ready dispatchers. Then we
can consider more tolerant dispatchers. Lifting the restriction will
not break any code. Other event handling frameworks have a similar
restriction, though it is usually more informal. For example the AWT:
http://java.sun.com/docs/books/tutorial/uiswing/events/generalrules.html
(first section of "Design Considerations").

The reason why I want to enforce "good behavior" of developers rather
than giving advice and hoping for the best is simple: bad experience.
I have seen code from a skilled developer who used an AWT event callback
to perform communication with a Smart Card, thereby triggering a
password dialog. The UI consisted of three or four windows which were
frozen for 30s or more - except for the password dialog of course.

> I thought differently of it and would certainly
> prefer both options.

I have pondered this more than once. There really isn't anything wrong
with handling a redirect (including a few KB of HTML) in the handler.
But it's Pandora's Box. Once you allow access to the response entity,
somebody *will* open a file and write several MB to it. That may not be
too bad as long as we have a thread or two per connection, but ultimately
we want to have fewer threads handling more connections.

That's why I have defined (though not explicitly written down) a few
restrictions. I know I can deliver useful dispatcher implementations
based on these restrictions, though they may be less simple to use than
most people would like them to be. As you have stated before, it is
better to have something that is useful with limitations, than to
work forever one something without limitations.
I don't consider these restrictions (see below) to remain standing for
eternity. It's just that I expect new problems for every one we drop.
I don't want to get distracted, neither by problems popping up in
real life, nor by myself constantly imagining what might go wrong.
Implementing dispatchers is hard enough as it is.

And for the records, here are the restrictions and/or design guidelines:

1. Application code is not trustworthy. To keep background threads
   stable, don't let them execute any more application code than is
   absolutely necessary.

2. Request preprocessing and response postprocessing are done by
   application threads, not by background threads. Interceptors are
   considered application code. See 1 about application code.

3. Notification handlers have to be called by the background threads.
   Make sure they delegate processing to application threads as soon
   as possible. Notification handlers are application code. See 1
   about application code.

4. Notification handlers do not get access to the response entity.
   Because of 2, the response is not and can not be postprocessed at
   the time the notification handler is called. The response entity
   might not be accessible without postprocessing in the first place,
   for example because of content decompression. Apart from that,
   processing huge response entities is the biggest temptation for
   developers to implement time consuming handler methods. Denying
   access to the response entity encourages 3.

The restriction that notification handlers are not allowed to call
handle.getResponse() or handle.awaitResponse() is a direct result of 2.
Both methods perform response postprocessing in the calling thread.

cheers,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 38943] - missing notification API for http-async

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38943>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38943





------- Additional Comments From olegk@apache.org  2006-03-23 16:43 -------
(1) OK. Now I know what I was missing. So, essentially you want the consumer of
the notification interface simply to queue the responses up for processing
rather than to process them. I thought differently of it and would certainly
prefer both options.

(2) I think NotifiedAsyncGet sample should be sufficient.

(3) Please consider merging the code from NotifiedServiceThread into
NotifiedAsyncGet (and RoutingAsyncGet if you decide to keep it). I think it is
important that the sample classes are completely self-contained.

Oleg

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org