-
Notifications
You must be signed in to change notification settings - Fork 38.8k
SPR-17458 Documentation explicit Executor usage on @Async section #2009
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3413,7 +3413,7 @@ The following table summarizes these registration behaviors: | |
| previous instance). | ||
| |=== | ||
|
|
||
| The values in the preceding table are defined as enums on the `RegistrationPolicy` class. | ||
| The values in the preceding table are defined as enums on the `RegistrationPolicy` class. | ||
| If you want to change the default registration behavior, you need to set the value of the | ||
| `registrationPolicy` property on your `MBeanExporter` definition to one of those | ||
| values. | ||
|
|
@@ -6680,8 +6680,35 @@ in combination with a custom pointcut. | |
| [[scheduling-annotation-support-qualification]] | ||
| ==== Executor Qualification with `@Async` | ||
|
|
||
| By default, when specifying `@Async` on a method, the executor that is used is the | ||
| one supplied to the "`annotation-driven`" element, as described earlier. However, you can use the `value` | ||
| As seen previously, you can enable the `@Async` annotation by adding `@EnableAsync` to any of your | ||
| `@Configuration` classes: | ||
|
|
||
| ==== | ||
| [source,java,indent=0] | ||
| [subs="verbatim,quotes"] | ||
| ---- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explaining how to configure Can we take a step back and can you describe why you'd want this to be added here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. The main purpose of this PR is as described on https://jira.spring.io/projects/SPR/issues/SPR-17458 to make more clear where the XML-based 'annotation-driven' element default considered executor is coming from. As also commented here unless there is a way to link directly to the referred In particular the initial section you are quoting here is indeed not related to the executor usage but I've included it because that's how I've interpreted the last section of the last phrase of the description of the ticket: 'and make sure it refers to annotations'. Unless I got it wrong of course - maybe it means an |
||
| @Configuration | ||
| @EnableAsync | ||
| public class AppConfig { | ||
| } | ||
| ---- | ||
| ==== | ||
|
|
||
| Or in the case of XML configuration: | ||
|
|
||
| ==== | ||
| [source,xml,indent=0] | ||
| [subs="verbatim,quotes"] | ||
| ---- | ||
| <task:annotation-driven executor="myExecutor" scheduler="myScheduler"/> | ||
| <task:executor id="myExecutor" pool-size="5"/> | ||
| <task:scheduler id="myScheduler" pool-size="10"/> | ||
| ---- | ||
| ==== | ||
|
|
||
| In the above XML configuration example in particular, the `"myExecutor"` executor | ||
| we are registering is the one that is getting used by default when specifying `@Async` on a method. | ||
| However, you can use the `value` | ||
| attribute of the `@Async` annotation when you need to indicate that an | ||
| executor other than the default should be used when executing a given method. | ||
| The following example shows how to do so: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks but that's unrelated to the purpose of the PR. I've fixed that in 8684650