Skip to content

Commit

Permalink
GH-861: Quick Tour Docs Polishing
Browse files Browse the repository at this point in the history
Resolves #861

* Increase latch wait time for Travis.
  • Loading branch information
garyrussell authored and artembilan committed Dec 3, 2018
1 parent 1195658 commit f0f9788
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public Message postProcessMessage(Message message, Correlation correlation) {
} }
exec.shutdown(); exec.shutdown();
assertTrue(exec.awaitTermination(300, TimeUnit.SECONDS)); assertTrue(exec.awaitTermination(300, TimeUnit.SECONDS));
assertTrue("" + mppLatch.getCount(), mppLatch.await(60, TimeUnit.SECONDS)); assertTrue("" + mppLatch.getCount(), mppLatch.await(300, TimeUnit.SECONDS));
assertTrue("" + latch.getCount(), latch.await(300, TimeUnit.SECONDS)); assertTrue("" + latch.getCount(), latch.await(300, TimeUnit.SECONDS));
assertNotNull(confirmCorrelation.get()); assertNotNull(confirmCorrelation.get());
assertEquals("abc", confirmCorrelation.get().getId()); assertEquals("abc", confirmCorrelation.get().getId());
Expand Down
62 changes: 58 additions & 4 deletions src/reference/asciidoc/quick-tour.adoc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,14 +28,30 @@ compile 'org.springframework.amqp:spring-rabbit:{spring-amqp-version}'
[[compatibility]] [[compatibility]]
===== Compatibility ===== Compatibility


The minimum Spring Framework version dependency is 5.0.x. The minimum Spring Framework version dependency is 5.1.x.


The minimum `amqp-client` java client library version is 5.0.0. The minimum `amqp-client` java client library version is 5.4.0.


===== Very, Very Quick ===== Very, Very Quick


**Imports for the following Java examples**

====
[source, java]
----
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
----
====

Using plain, imperative Java to send and receive a message: Using plain, imperative Java to send and receive a message:


====
[source,java] [source,java]
---- ----
ConnectionFactory connectionFactory = new CachingConnectionFactory(); ConnectionFactory connectionFactory = new CachingConnectionFactory();
Expand All @@ -45,16 +61,18 @@ AmqpTemplate template = new RabbitTemplate(connectionFactory);
template.convertAndSend("myqueue", "foo"); template.convertAndSend("myqueue", "foo");
String foo = (String) template.receiveAndConvert("myqueue"); String foo = (String) template.receiveAndConvert("myqueue");
---- ----
====


Note that there is a `ConnectionFactory` in the native Java Rabbit client as well. Note that there is a `ConnectionFactory` in the native Java Rabbit client as well.
We are using the Spring abstraction in the code above. We are using the Spring abstraction in the code above; it caches channels (and optionally connections) for reuse.
We are relying on the default exchange in the broker (since none is specified in the send), and the default binding of all queues to the default exchange by their name (hence we can use the queue name as a routing key in the send). We are relying on the default exchange in the broker (since none is specified in the send), and the default binding of all queues to the default exchange by their name (hence we can use the queue name as a routing key in the send).
Those behaviours are defined in the AMQP specification. Those behaviors are defined in the AMQP specification.


===== With XML Configuration ===== With XML Configuration


The same example as above, but externalizing the resource configuration to XML: The same example as above, but externalizing the resource configuration to XML:


====
[source,java] [source,java]
---- ----
ApplicationContext context = ApplicationContext context =
Expand Down Expand Up @@ -84,6 +102,7 @@ String foo = (String) template.receiveAndConvert("myqueue");
</beans> </beans>
---- ----
====


The `<rabbit:admin/>` declaration by default automatically looks for beans of type `Queue`, `Exchange` and `Binding` and declares them to the broker on behalf of the user, hence there is no need to use that bean explicitly in the simple Java driver. The `<rabbit:admin/>` declaration by default automatically looks for beans of type `Queue`, `Exchange` and `Binding` and declares them to the broker on behalf of the user, hence there is no need to use that bean explicitly in the simple Java driver.
There are plenty of options to configure the properties of the components in the XML schema - you can use auto-complete features of your XML editor to explore them and look at their documentation. There are plenty of options to configure the properties of the components in the XML schema - you can use auto-complete features of your XML editor to explore them and look at their documentation.
Expand All @@ -92,6 +111,7 @@ There are plenty of options to configure the properties of the components in the


The same example again with the external configuration in Java: The same example again with the external configuration in Java:


====
[source,java] [source,java]
---- ----
ApplicationContext context = ApplicationContext context =
Expand Down Expand Up @@ -126,3 +146,37 @@ public class RabbitConfiguration {
} }
} }
---- ----
====

===== With Spring Boot Auto Configuration and an Async POJO Listener

Spring Boot automatically configures the infrastructure beans:

====
[source, java]
----
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ApplicationRunner runner(AmqpTemplate template) {
return args -> template.convertAndSend("myqueue", "foo");
}
@Bean
public Queue myQueue() {
return new Queue("myqueue");
}
@RabbitListener(queues = "myqueue")
public void listen(String in) {
System.out.println(in);
}
}
----
====
2 changes: 1 addition & 1 deletion src/reference/asciidoc/whats-new.adoc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


===== AMQP Client library ===== AMQP Client library


Spring AMQP now uses the new 5.2.x version of the `amqp-client` library provided by the RabbitMQ team. Spring AMQP now uses the 5.4.x version of the `amqp-client` library provided by the RabbitMQ team.
This client has auto recovery configured by default; see <<auto-recovery>>. This client has auto recovery configured by default; see <<auto-recovery>>.


NOTE: As of version 4.0, the client enables automatic recovery by default; while compatible with this feature, Spring AMQP has its own recovery mechanisms and the client recovery feature generally isn't needed. NOTE: As of version 4.0, the client enables automatic recovery by default; while compatible with this feature, Spring AMQP has its own recovery mechanisms and the client recovery feature generally isn't needed.
Expand Down

0 comments on commit f0f9788

Please sign in to comment.