diff --git a/build.gradle b/build.gradle
index 0641ecc53f..f56b2f21df 100644
--- a/build.gradle
+++ b/build.gradle
@@ -201,6 +201,7 @@ configure(javaProjects) { subproject ->
compileTestJava {
sourceCompatibility = 11
+ options.encoding = 'UTF-8'
}
compileKotlin {
@@ -988,6 +989,7 @@ task checkAsciidocLinks {
asciidoctorPdf {
dependsOn checkAsciidocLinks
baseDirFollowsSourceFile()
+ configurations 'asciidoctorExt'
asciidoctorj {
sourceDir "$buildDir/asciidoc"
@@ -1006,11 +1008,31 @@ asciidoctorPdf {
}
}
+asciidoctorj {
+ version = '2.4.2'
+ options doctype: 'book', eruby: 'erubis'
+ attributes 'docinfo': 'shared',
+ stylesdir: 'css/',
+ stylesheet: 'stylesheet.css',
+ 'linkcss': true,
+ 'icons': 'font',
+ 'sectanchors': '',
+ 'source-highlighter': 'highlight.js',
+ 'highlightjsdir': 'js/highlight',
+ 'highlightjs-theme': 'github',
+ 'idprefix': '',
+ 'idseparator': '-',
+ 'allow-uri-read': '',
+ 'toc': 'left',
+ 'toclevels': '4',
+ revnumber: project.version,
+ 'project-version': project.version
+}
+
asciidoctor {
dependsOn asciidoctorPdf
-
baseDirFollowsSourceFile()
-
+ configurations 'asciidoctorExt'
sourceDir "$buildDir/asciidoc"
inputs.dir(sourceDir)
resources {
@@ -1018,25 +1040,7 @@ asciidoctor {
include 'images/*', 'css/**', 'js/**'
}
}
- options doctype: 'book'
- attributes 'docinfo': 'shared',
- stylesdir: 'css/',
- stylesheet: 'spring.css',
- 'linkcss': true,
- 'icons': 'font',
- 'sectanchors': '',
- 'source-highlighter': 'highlight.js',
- 'highlightjsdir': 'js/highlight',
- 'highlightjs-theme': 'github',
- 'idprefix': '',
- 'idseparator': '-',
- 'spring-version': project.version,
- 'allow-uri-read': '',
- 'toc': 'left',
- 'toclevels': '4',
- revnumber: project.version,
- 'project-version': project.version
}
task reference(dependsOn: asciidoctor) {
@@ -1224,3 +1228,5 @@ publishing {
}
}
}
+
+apply from: "${rootDir}/gradle/docs.gradle"
diff --git a/gradle/docs.gradle b/gradle/docs.gradle
new file mode 100644
index 0000000000..39642ca7b5
--- /dev/null
+++ b/gradle/docs.gradle
@@ -0,0 +1,7 @@
+configurations {
+ asciidoctorExt
+}
+
+dependencies {
+ asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.5.0")
+}
diff --git a/src/reference/asciidoc/amqp.adoc b/src/reference/asciidoc/amqp.adoc
index 1a7cdd2530..ec86b75c8e 100644
--- a/src/reference/asciidoc/amqp.adoc
+++ b/src/reference/asciidoc/amqp.adoc
@@ -6,8 +6,8 @@ Spring Integration provides channel adapters for receiving and sending messages
You need to include this dependency into your project:
====
+[source, xml, subs="normal", role="primary"]
.Maven
-[source, xml, subs="normal"]
----
org.springframework.integration
@@ -15,9 +15,8 @@ You need to include this dependency into your project:
{project-version}
----
-
+[source, groovy, subs="normal", role="secondary"]
.Gradle
-[source, groovy, subs="normal"]
----
compile "org.springframework.integration:spring-integration-amqp:{project-version}"
----
@@ -48,7 +47,57 @@ It provides much more in-depth information about Spring's integration with AMQP
The following listing shows the possible configuration options for an AMQP Inbound Channel Adapter:
====
-[source, xml]
+[source, java, role="primary"]
+.Java DSL
+----
+@Bean
+public IntegrationFlow amqpInbound(ConnectionFactory connectionFactory) {
+ return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "aName"))
+ .handle(m -> System.out.println(m.getPayload()))
+ .get();
+}
+----
+[source, java, role="secondary"]
+.Java
+----
+@Bean
+public MessageChannel amqpInputChannel() {
+ return new DirectChannel();
+}
+
+@Bean
+public AmqpInboundChannelAdapter inbound(SimpleMessageListenerContainer listenerContainer,
+ @Qualifier("amqpInputChannel") MessageChannel channel) {
+ AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
+ adapter.setOutputChannel(channel);
+ return adapter;
+}
+
+@Bean
+public SimpleMessageListenerContainer container(ConnectionFactory connectionFactory) {
+ SimpleMessageListenerContainer container =
+ new SimpleMessageListenerContainer(connectionFactory);
+ container.setQueueNames("aName");
+ container.setConcurrentConsumers(2);
+ // ...
+ return container;
+}
+
+@Bean
+@ServiceActivator(inputChannel = "amqpInputChannel")
+public MessageHandler handler() {
+ return new MessageHandler() {
+
+ @Override
+ public void handleMessage(Message> message) throws MessagingException {
+ System.out.println(message.getPayload());
+ }
+
+ };
+}
+----
+[source, xml, role="secondary"]
+.XML
----
@@ -172,12 +221,13 @@ See the https://docs.spring.io/spring-amqp/reference/html/[Spring AMQP Reference
When set to `MESSAGES` (default), the payload is a `List>` where each message has headers mapped from the incoming AMQP `Message` and the payload is the converted `body`.
When set to `EXTRACT_PAYLOADS`, the payload is a `List>` where the elements are converted from the AMQP `Message` body.
`EXTRACT_PAYLOADS_WITH_HEADERS` is similar to `EXTRACT_PAYLOADS` but, in addition, the headers from each message are mapped from the `MessageProperties` into a `List