Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cxz161530 committed May 28, 2024
2 parents 8e1cc5c + 04a15e9 commit f4e6c0f
Show file tree
Hide file tree
Showing 101 changed files with 2,867 additions and 0 deletions.
Empty file added .github/.keep
Empty file.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/TeamProject.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Iter1README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Details on RabbitMQ and Springboot set up.
## In step 1, need to access docker desktop and import the RabbitMQ, which is done via a search and then use of terminal to load that image.
See screenshots to ensure you choose the right RabbitMQ management tool.
## There are 2 steps associated with the terminal, the first of which is to pull the appropriate RabbitMQ version, and the 2nd is to run the RabbitMQ version to get to the RabbitMQ log in.
Once in RabbitMQ there are some quick exchange and queue set up and binding you can do to ensure you understand the relationships between Exchange and one, or many queues. In our project I have set up 2 queues, one being for JSON messages.
Many of the code that is used in this is from the Spring AMQP site, and there are screenshots too of how I have set up the message converters etc.
At different stages of setting up Producer, Consumer classes, i simply tested the output and connection to RabbitMQ, and it was working. The url is: http://localhost:8080/api/v1/publish when I had completed the task. At one point I simply sent message of "spring alert works" and that was a message that showed up in the Queue between Producer and consumer.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Group 1 Project
This is the currently the repo for the notification service that Team 1 will be building in support of the general classroom management system that the class as a whole is building.
There is no code yet, but in the docs/ directory there are supporting documents describing the design work we have done so far.
1 change: 1 addition & 0 deletions code/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains all source code and test code.
29 changes: 29 additions & 0 deletions code/metcs673-notification-service/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Read Me First
The following was discovered as part of building this project:

* The original package name 'edu.bu.metcs673-notification-service' is invalid and this project uses 'edu.bu.metcs673_notification_service' instead.

# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Gradle documentation](https://docs.gradle.org)
* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.2.6/gradle-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.2.6/gradle-plugin/reference/html/#build-image)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.2.6/reference/htmlsingle/index.html#web)
* [Spring for RabbitMQ](https://docs.spring.io/spring-boot/docs/3.2.6/reference/htmlsingle/index.html#messaging.amqp)

### Guides
The following guides illustrate how to use some features concretely:

* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Messaging with RabbitMQ](https://spring.io/guides/gs/messaging-rabbitmq/)

### Additional Links
These additional references should also help you:

* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)

60 changes: 60 additions & 0 deletions code/metcs673-notification-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Notification Service

This is a notification service built with Spring Boot and RabbitMQ. The service demonstrates the use of the Observer design pattern to send notifications via a RabbitMQ Fanout Exchange.

## Prerequisites

- Java 11 or higher
- RabbitMQ server
- Docker (optional, for running RabbitMQ)

## Getting Started

### Local running RabbitMQ(MacOS)
install RabbitMQ server with:
```
brew install rabbitmq
```
start a local RabbitMQ node:
```
brew services start rabbitmq
```
stop a running node:
```
brew services stop rabbitmq
```

### Running RabbitMQ with Docker

If you don't have RabbitMQ installed, you can run it using Docker:

```bash
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
```
Access the RabbitMQ management console at http://localhost:15672 with the default username and password (guest/guest)

### Clone repository
```
git clone https://github.com/yourusername/notification-service.git
cd notification-service
```

### Build & run the application
1.Build the application
```
./gradlew build
```
2.Run the application
```
./gradlew bootRun
```
### Testing
Use API client like Postman to send a POST request to /send-notification endpoint:

URL: http://localhost:8081/send-notification
Method: POST
Body:
Key:"message"
Value:"Hello World"

Check the logs of your Spring Boot application to see the received notifications
28 changes: 28 additions & 0 deletions code/metcs673-notification-service/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.6'
id 'io.spring.dependency-management' version '1.1.5'
}

group = 'edu.bu'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.amqp:spring-rabbit-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
<title>Test results - NotificationServiceApplicationTests</title>
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<script src="../js/report.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
<h1>NotificationServiceApplicationTests</h1>
<div class="breadcrumbs">
<a href="../index.html">all</a> &gt;
<a href="../packages/edu.bu.metcs673_notification_service.html">edu.bu.metcs673_notification_service</a> &gt; NotificationServiceApplicationTests</div>
<div id="summary">
<table>
<tr>
<td>
<div class="summaryGroup">
<table>
<tr>
<td>
<div class="infoBox" id="tests">
<div class="counter">1</div>
<p>tests</p>
</div>
</td>
<td>
<div class="infoBox" id="failures">
<div class="counter">0</div>
<p>failures</p>
</div>
</td>
<td>
<div class="infoBox" id="ignored">
<div class="counter">0</div>
<p>ignored</p>
</div>
</td>
<td>
<div class="infoBox" id="duration">
<div class="counter">0.511s</div>
<p>duration</p>
</div>
</td>
</tr>
</table>
</div>
</td>
<td>
<div class="infoBox success" id="successRate">
<div class="percent">100%</div>
<p>successful</p>
</div>
</td>
</tr>
</table>
</div>
<div id="tabs">
<ul class="tabLinks">
<li>
<a href="#tab0">Tests</a>
</li>
<li>
<a href="#tab1">Standard output</a>
</li>
</ul>
<div id="tab0" class="tab">
<h2>Tests</h2>
<table>
<thead>
<tr>
<th>Test</th>
<th>Duration</th>
<th>Result</th>
</tr>
</thead>
<tr>
<td class="success">contextLoads()</td>
<td class="success">0.511s</td>
<td class="success">passed</td>
</tr>
</table>
</div>
<div id="tab1" class="tab">
<h2>Standard output</h2>
<span class="code">
<pre>21:51:44.582 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [edu.bu.metcs673_notification_service.NotificationServiceApplicationTests]: NotificationServiceApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
21:51:44.630 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Found @SpringBootConfiguration edu.bu.metcs673_notification_service.NotificationServiceApplication for test class edu.bu.metcs673_notification_service.NotificationServiceApplicationTests

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.6)

2024-05-27T21:51:44.794-04:00 INFO 66733 --- [metcs673-notification-service] [ Test worker] .b.m.NotificationServiceApplicationTests : Starting NotificationServiceApplicationTests using Java 17.0.11 with PID 66733 (started by lishenxiao in /Users/lishenxiao/Dropbox/My Mac (Shenxiao’s MacBook Pro)/Desktop/BU Courses/CS 673 Software Engineering/project/metcs673-notification-service)
2024-05-27T21:51:44.795-04:00 INFO 66733 --- [metcs673-notification-service] [ Test worker] .b.m.NotificationServiceApplicationTests : No active profile set, falling back to 1 default profile: &quot;default&quot;
2024-05-27T21:51:45.444-04:00 INFO 66733 --- [metcs673-notification-service] [ Test worker] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [localhost:5672]
2024-05-27T21:51:45.474-04:00 INFO 66733 --- [metcs673-notification-service] [ Test worker] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#14924f41:0/SimpleConnection@5a05dd30 [delegate=amqp://guest@127.0.0.1:5672/, localPort=56251]
2024-05-27T21:51:45.502-04:00 INFO 66733 --- [metcs673-notification-service] [ Test worker] .b.m.NotificationServiceApplicationTests : Started NotificationServiceApplicationTests in 0.802 seconds (process running for 1.392)
</pre>
</span>
</div>
</div>
<div id="footer">
<p>
<div>
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 8.7</a> at May 27, 2024, 9:51:46 PM</p>
</div>
</div>
</body>
</html>
Loading

0 comments on commit f4e6c0f

Please sign in to comment.