-
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.
Merge pull request #250 from Azure/kaiqianyang/rabbitmq
refactor azure-message-queue rule and add spring amqp & rabbit
- Loading branch information
Showing
9 changed files
with
406 additions
and
161 deletions.
There are no files selected for viewing
244 changes: 244 additions & 0 deletions
244
rules/rules-reviewed/azure/azure-message-queue.windup.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
rules/rules-reviewed/azure/tests/azure-message-queue.windup.test.xml
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,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruletest id="azure-message-queue-test" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<testDataPath>data/azure-message-queue</testDataPath> | ||
<rulePath>../azure-message-queue.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="azure-message-queue-config-kafka-test-01000"> | ||
<when> | ||
<not> | ||
<iterable-filter size="3"> | ||
<hint-exists message="The application uses a Kafka connection string or password"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="azure-message-queue-config-kafka hint was not found!"/> | ||
</perform> | ||
</rule> | ||
<rule id="azure-message-queue-config-rabbitmq-test-01000"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The application uses a RabbitMQ connection string, username, or password"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="azure-message-queue-config-rabbitmq hint was not found!"/> | ||
</perform> | ||
</rule> | ||
<rule id="azure-message-queue-config-artemis-test-01000"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The application uses an ActiveMQ Artemis connection string, username, or password"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="azure-message-queue-config-artemis hint was not found!"/> | ||
</perform> | ||
</rule> | ||
<rule id="azure-message-queue-rabbitmq-test-01000"> | ||
<when> | ||
<not> | ||
<hint-exists message="The application uses Spring RabbitMQ based on Spring AMQP in code."/> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="azure-message-queue-rabbitmq-01000 hint was not found!"/> | ||
</perform> | ||
</rule> | ||
<rule id="azure-message-queue-amqp-test-01000"> | ||
<when> | ||
<not> | ||
<hint-exists message="The application uses Spring AMQP in code."/> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="azure-message-queue-amqp-01000 hint was not found!"/> | ||
</perform> | ||
</rule> | ||
<rule id="azure-message-queue-amqp-test-02000"> | ||
<when> | ||
<not> | ||
<hint-exists message="The application uses Spring AMQP dependency."/> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="azure-message-queue-amqp-02000 was not found!"/> | ||
</perform> | ||
</rule> | ||
|
||
</rules> | ||
</ruleset> | ||
</ruletest> |
48 changes: 0 additions & 48 deletions
48
rules/rules-reviewed/azure/tests/azure-mq-config.windup.test.xml
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
rules/rules-reviewed/azure/tests/data/azure-message-queue/RabbitRunner.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,30 @@ | ||
package com.example.messagingrabbitmq; | ||
|
||
import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static com.example.messagingrabbitmq.MessagingRabbitmqApplication.routingKey; | ||
|
||
@Component | ||
public class RabbitRunner implements CommandLineRunner { | ||
|
||
private final RabbitTemplate rabbitTemplate; | ||
private final Receiver receiver; | ||
|
||
public Runner(Receiver receiver, RabbitTemplate rabbitTemplate) { | ||
this.receiver = receiver; | ||
this.rabbitTemplate = rabbitTemplate; | ||
} | ||
|
||
@Override | ||
public void run(String... args) throws Exception { | ||
for (int i = 0; i < 10; i++) { | ||
System.out.println("Sending message..."+i); | ||
rabbitTemplate.convertAndSend(MessagingRabbitmqApplication.topicExchangeName, routingKey, "Hello from RabbitMQ!"+i); | ||
} | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
rules/rules-reviewed/azure/tests/data/azure-message-queue/pom.xml
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,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example</groupId> | ||
<artifactId>spring-rabbit-json</artifactId> | ||
<version>3.1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>spring-rabbit-json</name> | ||
<description>Receiving JSON from non-Spring Applications</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.2.0</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>17</java.version> | ||
<spring-amqp.version>${project.version}</spring-amqp.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-amqp</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>repository.springframework.maven.snapshots</id> | ||
<name>Spring Framework Repository Including Snapshots</name> | ||
<url>https://repo.spring.io/snapshot</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
</project> |