-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make RabbitMQ modules as auto-configuration
* Fix all the Checkstyle violations and compiler warnings * Add tests to these modules
- Loading branch information
1 parent
80e0b80
commit f509b15
Showing
14 changed files
with
178 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dependencies { | ||
api 'org.springframework.integration:spring-integration-amqp' | ||
api 'org.springframework.boot:spring-boot-starter-amqp' | ||
api 'org.springframework.boot:spring-boot-starter-web' | ||
|
||
testImplementation 'org.springframework.amqp:spring-rabbit-junit' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...bit-consumer/src/main/java/org/springframework/cloud/fn/consumer/rabbit/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* The RabbitMQ consumer auto-configuration support. | ||
*/ | ||
package org.springframework.cloud.fn.consumer.rabbit; |
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.cloud.fn.consumer.rabbit.RabbitConsumerConfiguration |
58 changes: 58 additions & 0 deletions
58
...sumer/src/test/java/org/springframework/cloud/fn/consumer/rabbit/RabbitConsumerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2016-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.fn.consumer.rabbit; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.amqp.rabbit.junit.RabbitAvailable; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.messaging.support.GenericMessage; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RabbitAvailable(RabbitConsumerTests.TEST_QUEUE) | ||
@SpringBootTest(properties = { "rabbit.consumer.routingKey=" + RabbitConsumerTests.TEST_QUEUE, | ||
"rabbit.consumer.own-connection=true" }) | ||
public class RabbitConsumerTests { | ||
|
||
static final String TEST_QUEUE = "test-consumer-queue"; | ||
|
||
@Test | ||
void rabbitSupplierReceivesData(@Autowired RabbitTemplate rabbitTemplate, | ||
@Autowired Consumer<Message<?>> rabbitConsumer) { | ||
|
||
rabbitConsumer.accept(new GenericMessage<>("test data1")); | ||
rabbitConsumer.accept(new GenericMessage<>("test data2")); | ||
|
||
Object received = rabbitTemplate.receiveAndConvert(TEST_QUEUE, 10_000); | ||
assertThat(received).isEqualTo("test data1"); | ||
received = rabbitTemplate.receiveAndConvert(TEST_QUEUE, 10_000); | ||
assertThat(received).isEqualTo("test data2"); | ||
} | ||
|
||
@SpringBootApplication | ||
public static class TestConfiguration { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dependencies { | ||
api 'org.springframework.integration:spring-integration-amqp' | ||
api 'org.springframework.boot:spring-boot-starter-amqp' | ||
api 'org.springframework.boot:spring-boot-starter-web' | ||
|
||
testImplementation 'org.springframework.amqp:spring-rabbit-junit' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.