Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: @Blocking #7228

Merged
merged 7 commits into from Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,21 @@
You can use the ann:core.annotation.Blocking[] annotation to mark methods as blocking.

If you set `micronaut.server.thread-selection` to `AUTO`, The Micronaut Framework offloads the execution of methods annotated with `@Blocking` to the IO thread pool (See: api:io.micronaut.scheduling.TaskExecutors[]).

NOTE: `@Blocking` only works if you are using `AUTO` thread selection. Micronaut Framework defaults to `MANUAL` thread selection since Micronaut 2.0. We recommend the usage of ann:scheduling.annotation.ExecuteOn[] annotation to execute the blocking operations on a different thread. `@ExecutesOn` works for both `MANUAL` or `AUTO` thread selection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NOTE: `@Blocking` only works if you are using `AUTO` thread selection. Micronaut Framework defaults to `MANUAL` thread selection since Micronaut 2.0. We recommend the usage of ann:scheduling.annotation.ExecuteOn[] annotation to execute the blocking operations on a different thread. `@ExecutesOn` works for both `MANUAL` or `AUTO` thread selection.
NOTE: `@Blocking` only works if you are using `AUTO` thread selection. Micronaut defaults to `MANUAL` thread selection since Micronaut 2.0. We recommend the usage of ann:scheduling.annotation.ExecuteOn[] annotation to execute the blocking operations on a different thread pool. `@ExecutesOn` works for both `MANUAL` and `AUTO` thread selection.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micronaut should not be used as a noun to match the brand guidelines. Hence, the Micronaut Framework

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have incorporated most of your suggestions here: e33ddf1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are gazillion places where simply "Micronaut" is used. Enforcing "Micronaut Framework" in every occurrence in the documentation is quite inappropriate, to say the least.


There are some places where the Micronaut framework uses ann:core.annotation.Blocking[] already.
sdelamo marked this conversation as resolved.
Show resolved Hide resolved

|===
|Blocking Type|Description

|link:{micronautapi}http/client/BlockingHttpClient.html[BlockingHttpClient]
| Intended for testing, and provides blocking versions for a subset of api:http.client.HttpClient[] operations.
sdelamo marked this conversation as resolved.
Show resolved Hide resolved
|link:{micronautapi}core/io/IOUtils.html[IOUtils]
| Reads the contents of a `BufferedReader` in a blocking manner, and returns that as a `String`.
|link:{micronautapi}context/env/BootstrapPropertySourceLocator.html[BootstrapPropertySourceLocator]
| Resolves either remote or local api:context.env.PropertySource[] instances for the current `Environment`.

|===

TIP: https://micronaut-projects.github.io/micronaut-data/latest/guide/[Micronaut Data] also utilizes `@Blocking` for some transaction operations, CRUD interceptors, and repositories.
sdelamo marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/main/docs/guide/toc.yml
Expand Up @@ -121,6 +121,7 @@ httpServer:
threadPools:
title: Configuring Server Thread Pools
blockingOperations: Blocking Operations
atBlocking: '@Blocking'
nettyPipeline: Configuring the Netty Pipeline
cors: Configuring CORS
https: Securing the Server with HTTPS
Expand Down