Class HttpRequestReceivedEvent

java.lang.Object
java.util.EventObject
io.micronaut.context.event.ApplicationEvent
io.micronaut.http.context.event.HttpRequestReceivedEvent
All Implemented Interfaces:
Serializable

public class HttpRequestReceivedEvent extends ApplicationEvent
An event fired when an HttpRequest is received by the server, before the request is routed. Access to the request body is not provided. Consumers can use this event to trace the URI, headers and so on but should not perform I/O.

Listeners are invoked on the thread the server selects for request handling, which with the default micronaut.server.thread-selection (MANUAL, and also with AUTO) is the Netty event loop that received the request. Every listener runs to completion before the request is routed, so a listener that blocks or does slow work delays this request and every other connection on that event loop. Listeners that need to block must hand off, for example with @Async on the @EventListener method, or the server can be configured with micronaut.server.thread-selection=BLOCKING which moves the listeners (and controllers) off the event loop.

Since:
1.2.0
Author:
graemerocher
See Also:
  • Constructor Details

    • HttpRequestReceivedEvent

      public HttpRequestReceivedEvent(HttpRequest<?> request)
      Parameters:
      request - The request. Never null.
  • Method Details