Sync docs from master to gh-pages
This commit is contained in:
@@ -719,7 +719,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p><em>Documentation Authors: Adam Dudczak, Marcin Grzejszczak, Jakub Kubryński, Karol Lassak,
|
||||
Olga Maciaszek-Sharma, Mariusz Smykuła, Dave Syer</em></p>
|
||||
Olga Maciaszek-Sharma, Mariusz Smykuła, Dave Syer, Mathias Düsterhöft</em></p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>1.0.2.BUILD-SNAPSHOT</p>
|
||||
@@ -5235,26 +5235,24 @@ For the provided artifacts it will automatically download the stubs and register
|
||||
routes.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The integration tries to work standalone, that is without interaction with a running RabbitMQ message broker. It expects a <code>RabbitTemplate</code> on the application context and uses it as a spring boot test <code>@SpyBean</code>.
|
||||
<p>The integration tries to work standalone, that is without interaction with a running RabbitMQ message broker.
|
||||
It expects a <code>RabbitTemplate</code> on the application context and uses it as a spring boot test <code>@SpyBean</code>.
|
||||
Thus it can use the mockito spy functionality to verify and introspect messages sent by the application.</p>
|
||||
</div>
|
||||
<div class="admonitionblock important">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<div class="title">Important</div>
|
||||
</td>
|
||||
<td class="content">
|
||||
In the current status of the implementation tries to find a <code>MessageListenerAdapter</code> on the application context to send messages into the application, because we want to avoid interacting with a running bus.
|
||||
Using annotation driven listener endpoints (e.g. <code>@RabbitListener</code> annotated listener methods) is currently not supported.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="paragraph">
|
||||
<p>On the message consumer side, it considers all <code>@RabbitListener</code> annotated endpoints as well as all `SimpleMessageListenerContainer`s on the application context.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>As messages are usually sent to exchanges in AMQP the message contract contains the exchange name as the destination.
|
||||
Message listeners on the other side are bound to queues. Bindings connect an exchange to a queue.
|
||||
If message contracts are triggered the Spring AMQP stub runner integration will look for bindings on the application context that match this exchange.
|
||||
Then it collects the queues from the Spring exchanges and tries to find messages listeners bound to these queues.
|
||||
The message is triggered to all matching message listeners.</p>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="_adding_it_to_the_project_4">Adding it to the project</h4>
|
||||
<div class="paragraph">
|
||||
<p>It’s enough to have both Spring AMQP and Spring Cloud Contract Stub Runner on classpath.
|
||||
<p>It’s enough to have both Spring AMQP and Spring Cloud Contract Stub Runner on the classpath.
|
||||
Remember to annotate your test class with <code>@AutoConfigureMessageVerifier</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5343,6 +5341,60 @@ stubrunner.ids: org.springframework.cloud.contract.verifier.stubs.amqp:spring-cl
|
||||
<pre class="highlight"><code class="language-groovy" data-lang="groovy">stubTrigger.trigger("contract-test.person.created.event")</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The message has the destination <code>contract-test.exchange</code> so the Spring AMQP stub runner integration looks for bindings related to this exchange.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">@Bean
|
||||
public Binding binding() {
|
||||
return BindingBuilder.bind(new Queue("test.queue")).to(new DirectExchange("contract-test.exchange")).with("#");
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The binding definition binds the queue <code>test.queue</code>.
|
||||
So the following listener definition is a match and is invoked with the contract message.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">@Bean
|
||||
public SimpleMessageListenerContainer simpleMessageListenerContainer(ConnectionFactory connectionFactory,
|
||||
MessageListenerAdapter listenerAdapter) {
|
||||
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
container.setQueueNames("test.queue");
|
||||
container.setMessageListener(listenerAdapter);
|
||||
|
||||
return container;
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Also, the following annotated listener represents a match and would be invoked.</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(value = "test.queue"),
|
||||
exchange = @Exchange(value = "contract-test.exchange", ignoreDeclarationExceptions = "true")))
|
||||
public void handlePerson(Person person) {
|
||||
this.person = person;
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admonitionblock note">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<div class="title">Note</div>
|
||||
</td>
|
||||
<td class="content">
|
||||
The message is directly handed over to the <code>onMessage</code> method of the <code>MessageListener</code> associated with the matching <code>SimpleMessageListenerContainer</code>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect4">
|
||||
<h5 id="_spring_amqp_test_configuration">Spring AMQP Test Configuration</h5>
|
||||
|
||||
Reference in New Issue
Block a user