public class SpringAmqpStubMessages extends Object implements MessageVerifier<org.springframework.amqp.core.Message>
MessageVerifier
implementation to integrate with plain
spring-amqp/spring-rabbit. It is meant to be used without interacting with a running
bus.
It relies on the RabbitTemplate to be a spy to be able to capture send messages.
Messages are not sent to the bus - but are handed over to a
SimpleMessageListenerContainer
which allows us to test the full deserialization
and listener invocation.Constructor and Description |
---|
SpringAmqpStubMessages(org.springframework.amqp.rabbit.core.RabbitTemplate rabbitTemplate,
org.springframework.cloud.contract.verifier.messaging.amqp.MessageListenerAccessor messageListenerAccessor,
org.springframework.boot.autoconfigure.amqp.RabbitProperties rabbitProperties) |
Modifier and Type | Method and Description |
---|---|
boolean |
isInputMessage(ContractVerifierMessageMetadata messageMetadata) |
void |
mergeMessagePropertiesFromMetadata(YamlContract contract,
org.springframework.amqp.core.Message message) |
org.springframework.amqp.core.Message |
receive(String destination,
long timeout,
TimeUnit timeUnit,
YamlContract contract)
Receives the message from the given destination.
|
org.springframework.amqp.core.Message |
receive(String destination,
YamlContract contract)
Receives the message from the given destination.
|
void |
send(org.springframework.amqp.core.Message message,
String destination,
YamlContract contract)
Sends the message to the given destination.
|
<T> void |
send(T payload,
Map<String,Object> headers,
String destination,
YamlContract contract)
Sends the given payload with headers, to the given destination.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
send, send
receive, receive
@Autowired public SpringAmqpStubMessages(org.springframework.amqp.rabbit.core.RabbitTemplate rabbitTemplate, org.springframework.cloud.contract.verifier.messaging.amqp.MessageListenerAccessor messageListenerAccessor, org.springframework.boot.autoconfigure.amqp.RabbitProperties rabbitProperties)
public <T> void send(T payload, Map<String,Object> headers, String destination, YamlContract contract)
MessageVerifierSender
send
in interface MessageVerifierSender<org.springframework.amqp.core.Message>
T
- payload typepayload
- payload to sendheaders
- headers to senddestination
- destination to which the message will be sentcontract
- contract related to this methodpublic void mergeMessagePropertiesFromMetadata(YamlContract contract, org.springframework.amqp.core.Message message)
public boolean isInputMessage(ContractVerifierMessageMetadata messageMetadata)
public void send(org.springframework.amqp.core.Message message, String destination, YamlContract contract)
MessageVerifierSender
send
in interface MessageVerifierSender<org.springframework.amqp.core.Message>
message
- to senddestination
- destination to which the message will be sentcontract
- contract related to this methodpublic org.springframework.amqp.core.Message receive(String destination, long timeout, TimeUnit timeUnit, YamlContract contract)
MessageVerifierReceiver
receive
in interface MessageVerifierReceiver<org.springframework.amqp.core.Message>
destination
- destination from which the message will be receivedtimeout
- timeout to wait for the messagetimeUnit
- param to define the unit of timeoutcontract
- contract related to this methodpublic org.springframework.amqp.core.Message receive(String destination, YamlContract contract)
MessageVerifierReceiver
receive
in interface MessageVerifierReceiver<org.springframework.amqp.core.Message>
destination
- destination from which the message will be receivedcontract
- contract related to this methodCopyright © 2016–2021 Spring. All rights reserved.