упаковал всё в docker-compose
This commit is contained in:
12
lab3/.gitignore
vendored
12
lab3/.gitignore
vendored
@@ -1,9 +1,3 @@
|
|||||||
*
|
*.jpg
|
||||||
!.gitignore
|
*.pdf
|
||||||
!report
|
*.docx
|
||||||
!report/**
|
|
||||||
!producer
|
|
||||||
!producer/**
|
|
||||||
!consumer
|
|
||||||
!consumer/**
|
|
||||||
!my-variant.txt
|
|
||||||
9
lab3/consumer/Dockerfile
Normal file
9
lab3/consumer/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
FROM gradle:8.13-jdk21
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN gradle build --no-daemon
|
||||||
|
|
||||||
|
CMD ["gradle", "run", "--no-daemon"]
|
||||||
@@ -10,7 +10,7 @@ public class Recv {
|
|||||||
|
|
||||||
public static void main(String[] argv) throws Exception {
|
public static void main(String[] argv) throws Exception {
|
||||||
ConnectionFactory factory = new ConnectionFactory();
|
ConnectionFactory factory = new ConnectionFactory();
|
||||||
factory.setHost("localhost");
|
factory.setHost("rabbitmq");
|
||||||
Connection connection = factory.newConnection();
|
Connection connection = factory.newConnection();
|
||||||
Channel channel = connection.createChannel();
|
Channel channel = connection.createChannel();
|
||||||
|
|
||||||
|
|||||||
41
lab3/docker-compose.yml
Normal file
41
lab3/docker-compose.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
services:
|
||||||
|
rabbitmq:
|
||||||
|
image: rabbitmq:4.0-management
|
||||||
|
hostname: rabbitmq
|
||||||
|
container_name: rabbitmq
|
||||||
|
ports:
|
||||||
|
- "5672:5672"
|
||||||
|
- "15672:15672"
|
||||||
|
networks:
|
||||||
|
- rabbitnet
|
||||||
|
|
||||||
|
producer1:
|
||||||
|
container_name: producer1
|
||||||
|
build:
|
||||||
|
context: ./producer
|
||||||
|
depends_on:
|
||||||
|
- rabbitmq
|
||||||
|
networks:
|
||||||
|
- rabbitnet
|
||||||
|
|
||||||
|
producer2:
|
||||||
|
container_name: producer2
|
||||||
|
build:
|
||||||
|
context: ./producer
|
||||||
|
depends_on:
|
||||||
|
- rabbitmq
|
||||||
|
networks:
|
||||||
|
- rabbitnet
|
||||||
|
|
||||||
|
consumer:
|
||||||
|
container_name: consumer
|
||||||
|
build:
|
||||||
|
context: ./consumer
|
||||||
|
depends_on:
|
||||||
|
- rabbitmq
|
||||||
|
networks:
|
||||||
|
- rabbitnet
|
||||||
|
|
||||||
|
networks:
|
||||||
|
rabbitnet:
|
||||||
|
driver: bridge
|
||||||
9
lab3/producer/Dockerfile
Normal file
9
lab3/producer/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
FROM gradle:8.13-jdk21
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN gradle build --no-daemon
|
||||||
|
|
||||||
|
CMD ["gradle", "run", "--no-daemon"]
|
||||||
@@ -9,7 +9,7 @@ public class Send {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ConnectionFactory factory = new ConnectionFactory();
|
ConnectionFactory factory = new ConnectionFactory();
|
||||||
factory.setHost("localhost");
|
factory.setHost("rabbitmq");
|
||||||
try (Connection connection = factory.newConnection();
|
try (Connection connection = factory.newConnection();
|
||||||
Channel channel = connection.createChannel()) {
|
Channel channel = connection.createChannel()) {
|
||||||
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user