Use convention based code imports
Closes gh-29647
This commit is contained in:
@@ -49,10 +49,7 @@ TIP: See https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used-
|
||||
=== Sending a Message
|
||||
Spring's `AmqpTemplate` and `AmqpAdmin` are auto-configured, and you can autowire them directly into your own beans, as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/amqp/sending/MyBean.java[]
|
||||
----
|
||||
include::code:MyBean[]
|
||||
|
||||
NOTE: {spring-amqp-api}/rabbit/core/RabbitMessagingTemplate.html[`RabbitMessagingTemplate`] can be injected in a similar manner.
|
||||
If a `MessageConverter` bean is defined, it is associated automatically to the auto-configured `AmqpTemplate`.
|
||||
@@ -104,10 +101,7 @@ If a `MessageConverter` or a `MessageRecoverer` bean is defined, it is automatic
|
||||
|
||||
The following sample component creates a listener endpoint on the `someQueue` queue:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/amqp/receiving/MyBean.java[]
|
||||
----
|
||||
include::code:MyBean[]
|
||||
|
||||
TIP: See {spring-amqp-api}/rabbit/annotation/EnableRabbit.html[the Javadoc of `@EnableRabbit`] for more details.
|
||||
|
||||
@@ -118,17 +112,11 @@ Those two beans are exposed by the auto-configuration.
|
||||
|
||||
For instance, the following configuration class exposes another factory that uses a specific `MessageConverter`:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/amqp/receiving/custom/MyRabbitConfiguration.java[]
|
||||
----
|
||||
include::code:custom/MyRabbitConfiguration[]
|
||||
|
||||
Then you can use the factory in any `@RabbitListener`-annotated method, as follows:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/amqp/receiving/custom/MyBean.java[]
|
||||
----
|
||||
include::code:custom/MyBean[]
|
||||
|
||||
You can enable retries to handle situations where your listener throws an exception.
|
||||
By default, `RejectAndDontRequeueRecoverer` is used, but you can define a `MessageRecoverer` of your own.
|
||||
|
||||
@@ -140,10 +140,7 @@ You can use the configprop:spring.jms.jndi-name[] property if you need to specif
|
||||
=== Sending a Message
|
||||
Spring's `JmsTemplate` is auto-configured, and you can autowire it directly into your own beans, as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/jms/sending/MyBean.java[]
|
||||
----
|
||||
include::code:MyBean[]
|
||||
|
||||
NOTE: {spring-framework-api}/jms/core/JmsMessagingTemplate.html[`JmsMessagingTemplate`] can be injected in a similar manner.
|
||||
If a `DestinationResolver` or a `MessageConverter` bean is defined, it is associated automatically to the auto-configured `JmsTemplate`.
|
||||
@@ -165,10 +162,7 @@ This also includes sending response messages that have been performed on the sam
|
||||
|
||||
The following component creates a listener endpoint on the `someQueue` destination:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/jms/receiving/MyBean.java[]
|
||||
----
|
||||
include::code:MyBean[]
|
||||
|
||||
TIP: See {spring-framework-api}/jms/annotation/EnableJms.html[the Javadoc of `@EnableJms`] for more details.
|
||||
|
||||
@@ -176,14 +170,8 @@ If you need to create more `JmsListenerContainerFactory` instances or if you wan
|
||||
|
||||
For instance, the following example exposes another factory that uses a specific `MessageConverter`:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/jms/receiving/custom/MyJmsConfiguration.java[]
|
||||
----
|
||||
include::code:custom/MyJmsConfiguration[]
|
||||
|
||||
Then you can use the factory in any `@JmsListener`-annotated method as follows:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/jms/receiving/custom/MyBean.java[]
|
||||
----
|
||||
include::code:custom/MyBean[]
|
||||
|
||||
@@ -25,10 +25,7 @@ See {spring-boot-autoconfigure-module-code}/kafka/KafkaProperties.java[`KafkaPro
|
||||
=== Sending a Message
|
||||
Spring's `KafkaTemplate` is auto-configured, and you can autowire it directly in your own beans, as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/kafka/sending/MyBean.java[]
|
||||
----
|
||||
include::code:MyBean[]
|
||||
|
||||
NOTE: If the property configprop:spring.kafka.producer.transaction-id-prefix[] is defined, a `KafkaTransactionManager` is automatically configured.
|
||||
Also, if a `RecordMessageConverter` bean is defined, it is automatically associated to the auto-configured `KafkaTemplate`.
|
||||
@@ -42,10 +39,7 @@ If no `KafkaListenerContainerFactory` has been defined, a default one is automat
|
||||
|
||||
The following component creates a listener endpoint on the `someTopic` topic:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/kafka/receiving/MyBean.java[]
|
||||
----
|
||||
include::code:MyBean[]
|
||||
|
||||
If a `KafkaTransactionManager` bean is defined, it is automatically associated to the container factory.
|
||||
Similarly, if a `RecordFilterStrategy`, `ErrorHandler`, `CommonErrorHandler`, `AfterRollbackProcessor` or `ConsumerAwareRebalanceListener` bean is defined, it is automatically associated to the default factory.
|
||||
@@ -71,10 +65,7 @@ See also <<features#messaging.kafka.additional-properties>> for more information
|
||||
|
||||
To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/kafka/streams/MyKafkaStreamsConfiguration.java[]
|
||||
----
|
||||
include::code:MyKafkaStreamsConfiguration[]
|
||||
|
||||
By default, the streams managed by the `StreamBuilder` object it creates are started automatically.
|
||||
You can customize this behavior using the configprop:spring.kafka.streams.auto-startup[] property.
|
||||
@@ -156,17 +147,11 @@ There are several ways to do that:
|
||||
|
||||
* Provide a system property to map embedded broker addresses into configprop:spring.kafka.bootstrap-servers[] in the test class:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/kafka/embedded/property/MyTest.java[tag=*]
|
||||
----
|
||||
include::code:property/MyTest[tag=*]
|
||||
|
||||
* Configure a property name on the `@EmbeddedKafka` annotation:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/kafka/embedded/annotation/MyTest.java[]
|
||||
----
|
||||
include::code:annotation/MyTest[]
|
||||
|
||||
* Use a placeholder in configuration properties:
|
||||
|
||||
|
||||
@@ -80,7 +80,4 @@ This is done on purpose since this builder is stateful and you should not create
|
||||
|
||||
The following code shows a typical example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/messaging/rsocket/requester/MyService.java[]
|
||||
----
|
||||
include::code:MyService[]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[[messaging.whats-next]]
|
||||
== What to Read Next
|
||||
The next section describes how to enable <<io#io, IO capabilities>> in your application.
|
||||
You can read about <<io#io.caching, caching>>, <<io#io.email, mail>>, <<io#io.validation, validation>>, <<io#io.rest-client, rest clients>> and more in this section.
|
||||
You can read about <<io#io.caching, caching>>, <<io#io.email, mail>>, <<io#io.validation, validation>>, <<io#io.rest-client, rest clients>> and more in this section.
|
||||
|
||||
Reference in New Issue
Block a user