Skip to content

Commit

Permalink
Merge pull request #250 from Azure/kaiqianyang/rabbitmq
Browse files Browse the repository at this point in the history
refactor azure-message-queue rule and add spring amqp & rabbit
  • Loading branch information
KaiqianYang authored Aug 21, 2024
2 parents fe393d1 + 2e4615e commit 6046838
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 161 deletions.
244 changes: 244 additions & 0 deletions rules/rules-reviewed/azure/azure-message-queue.windup.xml

Large diffs are not rendered by default.

113 changes: 0 additions & 113 deletions rules/rules-reviewed/azure/azure-mq-config.windup.xml

This file was deleted.

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 rules/rules-reviewed/azure/tests/azure-mq-config.windup.test.xml

This file was deleted.

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);
}
}

}
53 changes: 53 additions & 0 deletions rules/rules-reviewed/azure/tests/data/azure-message-queue/pom.xml
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>

0 comments on commit 6046838

Please sign in to comment.