Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions src/docs/asciidoc/integration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

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

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.
Expand Down Expand Up @@ -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"]
----
Copy link
Member

Choose a reason for hiding this comment

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

Explaining how to configure @EnableAsync in a section named "Executor Qualification with @Async" looks odd to me. This is also a copy/paste of the javadoc of @EnableAsync so I am not too keen to duplicate that.

Can we take a step back and can you describe why you'd want this to be added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 task:annotation-driven XML definition (which in my opinion is a better approach), duplicating it in this section is the only other way.

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 @Bean Java Config definition of an Executor?

@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:
Expand Down