[undertow-dev] what I do wrong?
Mikhail Tyamin
mikhail.tiamine at gmail.com
Tue Feb 18 01:10:32 EST 2014
Hi,
I am pretty sure, 15 sec. delay is enough to open additional browsers
windows ;-)
I try to run code with io.undertow:undertow-core:1.0.0.Final on mac with OS
X 10.9.1 with jdk 1.7.0_51.
So, could anybody reproduce this issue or give me feedback where is my
error?
Best,
Mikhail
2014-02-18 5:22 GMT+02:00 Stuart Douglas <sdouglas at redhat.com>:
> Are you sure the requests are actually being made simultaneously? That
> code should definitely work.
>
> Stuart
>
>
> ----- Original Message -----
> > From: "Mikhail Tyamin" <mikhail.tiamine at gmail.com>
> > To: undertow-dev at lists.jboss.org
> > Sent: Monday, 17 February, 2014 3:03:41 PM
> > Subject: [undertow-dev] what I do wrong?
> >
> > Hello guys,
> >
> > could you help me a little bit with Undertow?
> >
> > I follow all instructions in Undertown's poor documentation. So here is
> the
> > class :
> >
> > public class HelloWorldServer {
> >
> > public static void main(String... args) {
> > Undertow server = Undertow.builder()
> > .addHttpListener(8080, "localhost")
> > .setHandler(new HttpHandler() {
> > @Override
> > public void handleRequest(final HttpServerExchange exchange) throws
> Exception
> > {
> > if (exchange.isInIoThread()) {
> > System.out.println("Thread #" + Thread.currentThread().getName() + " is
> I/O :
> > handle this");
> > exchange.dispatch(this);
> > return;
> > }
> >
> > //[1]
> > System.out.println("Thread #" + Thread.currentThread().getName() + "
> Start
> > waiting");
> > Thread.sleep(15000);
> > System.out.println("Thread #" + Thread.currentThread().getName() + "
> Finish
> > waiting");
> >
> > System.out.println();
> >
> > exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
> > exchange.getResponseSender().send("Hello world from thread " +
> > Thread.currentThread().getId());
> > //[2]
> > }
> > }).build();
> >
> > server.start();
> > }
> > }
> >
> > When I start it and make three http get request simultaneously I can see
> this
> > output in console :
> >
> > Thread #XNIO-1 I/O-1 is I/O : handle this
> > Thread #XNIO-1 task-1 Start waiting
> > Thread #XNIO-1 task-1 Finish waiting
> >
> > Thread #XNIO-1 I/O-1 is I/O : handle this
> > Thread #XNIO-1 task-2 Start waiting
> > Thread #XNIO-1 task-2 Finish waiting
> >
> > Thread #XNIO-1 I/O-1 is I/O : handle this
> > Thread #XNIO-1 task-3 Start waiting
> > Thread #XNIO-1 task-3 Finish waiting
> >
> >
> > I think that code beetween //[1] and //[2] should perform in separate
> thread
> > (and as we can see from the console it really does), but why the main I/O
> > thread are waiting and does not handle other requests?
> >
> > So if my code is correct than it means that Undertow could handle one
> request
> > in time...
> >
> > What I do wrong?
> >
> > Best,
> > Mikhail
> >
> > _______________________________________________
> > undertow-dev mailing list
> > undertow-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/undertow-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20140218/b73db65c/attachment-0001.html
More information about the undertow-dev
mailing list