use of org.springframework.cloud.gcp.pubsub.support.BasicAcknowledgeablePubsubMessage in project spring-cloud-gcp by spring-cloud.
the class PubSubChannelAdaptersIntegrationTests method sendAndReceiveMessageManualAck.
@Test
public void sendAndReceiveMessageManualAck() {
this.contextRunner.withUserConfiguration(PollableConfiguration.class, CommonConfiguration.class).run((context) -> {
context.getBean(PubSubInboundChannelAdapter.class).setAckMode(AckMode.MANUAL);
context.getBean("inputChannel", MessageChannel.class).send(MessageBuilder.withPayload("I am a message (sendAndReceiveMessageManualAck).".getBytes()).build());
PollableChannel channel = context.getBean("outputChannel", PollableChannel.class);
Message<?> message = channel.receive(RECEIVE_TIMEOUT_MS);
assertThat(message).isNotNull();
BasicAcknowledgeablePubsubMessage origMessage = (BasicAcknowledgeablePubsubMessage) message.getHeaders().get(GcpPubSubHeaders.ORIGINAL_MESSAGE);
assertThat(origMessage).isNotNull();
origMessage.nack();
message = channel.receive(RECEIVE_TIMEOUT_MS);
assertThat(message).isNotNull();
origMessage = (BasicAcknowledgeablePubsubMessage) message.getHeaders().get(GcpPubSubHeaders.ORIGINAL_MESSAGE);
assertThat(origMessage).isNotNull();
origMessage.ack();
message = channel.receive(RECEIVE_TIMEOUT_MS);
assertThat(message).isNull();
});
}
Aggregations