Compare commits
257 Commits
bazunov_an
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
5dd9e26f07 | ||
60e2c7996c | |||
95d2554f95 | |||
d9c57f2e8e | |||
158c0670a4 | |||
df8cf26c03 | |||
9495f5cd12 | |||
9e71d368c8 | |||
5c8dbc4ae3 | |||
e89eb8fc8d | |||
a74ea43db8 | |||
f1afb24c8b | |||
2c12d97510 | |||
00c170a00c | |||
c620f10752 | |||
e46d33bc4d | |||
1a11fca0e4 | |||
db9395340c | |||
9485011484 | |||
75c4fde178 | |||
93f689f155 | |||
6e224cf288 | |||
a9fba22e19 | |||
d7008ca1e5 | |||
3fb94595bc | |||
14de0603a8 | |||
31346e7082 | |||
fc6f211197 | |||
b5944df141 | |||
|
1812ac159e | ||
fa4c181ac0 | |||
4343669b5a | |||
d95e2a9d3a | |||
2f9c00b03b | |||
51af80f3ad | |||
1fffeaa7e9 | |||
a463ec8241 | |||
7a1ba7aa9a | |||
08cc99b0fc | |||
6556e21d9a | |||
7accd18aea | |||
bfc6d8bb95 | |||
cdd0a7b7c9 | |||
27850eb504 | |||
6feebae507 | |||
1648f5995a | |||
bf8d06a85d | |||
de0f1780c7 | |||
e54fd14090 | |||
ce580c4572 | |||
84f32a0993 | |||
7a36b2b0af | |||
02d6165c7e | |||
18c838d58c | |||
9d6529c11d | |||
1dc61d09d4 | |||
84edc080bd | |||
885ad1ffec | |||
4b1c9666a0 | |||
135f79e158 | |||
62b20a244e | |||
e8f3643fd1 | |||
2a388e9788 | |||
3be8ceb996 | |||
84786b8531 | |||
6b370579f8 | |||
a608e3a24b | |||
4f7d9d4ba1 | |||
547212dca6 | |||
58f4127148 | |||
f12a88ed52 | |||
e3979acf4d | |||
8640f9e8fc | |||
c26a7b8d97 | |||
29320bae24 | |||
5449675d39 | |||
b895c806e7 | |||
920dec1ede | |||
fdba824237 | |||
|
10a12d8da0 | ||
25b2a2c481 | |||
c699558126 | |||
4226945dca | |||
239da31a0d | |||
693c6bd91d | |||
31c074f6bb | |||
21c4aa5f5e | |||
|
75b27fd1f5 | ||
|
05293340a3 | ||
|
ef4acd4ec6 | ||
|
356bb54247 | ||
c9b601dda5 | |||
a3dc157784 | |||
c06d3e291b | |||
4c83bd29bf | |||
|
a3827d5b4b | ||
b64b354a74 | |||
8ef7197268 | |||
8e5776d104 | |||
25f8ce44eb | |||
a25c242bda | |||
429ab85f80 | |||
681b9b4c00 | |||
ae4ba4c88d | |||
91b02cece8 | |||
fb3994fcab | |||
af77bb1076 | |||
3fb0096475 | |||
752036c0ae | |||
|
544d4c2714 | ||
5247783708 | |||
7e69d49c4d | |||
753e2f6593 | |||
055bb25d6b | |||
e760640200 | |||
|
063b93d78e | ||
|
44a4ee7eec | ||
3df2cc1a48 | |||
8c5f33678e | |||
|
2cfe26ee1b | ||
ee80d0ffdd | |||
63854633e1 | |||
b38e755299 | |||
|
65121a52d7 | ||
|
7811d112d9 | ||
|
abea29a111 | ||
|
529b2c8782 | ||
db8939f045 | |||
|
219c77a03f | ||
8462ae9c2f | |||
a5a422fc0f | |||
a1bca21933 | |||
6f030312a7 | |||
2fc7e3e67f | |||
9bbe7b8b53 | |||
0add49368f | |||
41d7a3d8fd | |||
bc087de470 | |||
a4cf38e0c5 | |||
7da1307156 | |||
9fd3c9ba1f | |||
6ea7581574 | |||
ce3325db81 | |||
22dd0c1a6f | |||
506d1bb364 | |||
d70e738ef0 | |||
183054d1d4 | |||
574e9bba1b | |||
898f188739 | |||
8985b761bd | |||
043da1373f | |||
972d1442f3 | |||
5b6a3e7971 | |||
46da8f27b8 | |||
1dc8fb7ecd | |||
4347288bb2 | |||
b63718633c | |||
46e167424e | |||
7002b58201 | |||
a3c467e867 | |||
e7a219301e | |||
bc54fabeb5 | |||
90206c821f | |||
|
f6614533d7 | ||
|
3ef7c65962 | ||
|
9808787f27 | ||
|
e61cfe3336 | ||
|
b6079c266e | ||
7f5ad611b5 | |||
014088a385 | |||
a171fb7572 | |||
e01e3267c6 | |||
271ce7249c | |||
0887bc1d98 | |||
5dbc6a294b | |||
df05f3f538 | |||
06873933fe | |||
|
69f42f260e | ||
|
cdaa75298a | ||
|
4390166883 | ||
287fb33386 | |||
9ff5b267bc | |||
|
6beff3a600 | ||
9d7821b12b | |||
07a49d9b7b | |||
|
8546d15925 | ||
ead1821703 | |||
ba0da1d0d4 | |||
ad560d4736 | |||
ed5444768f | |||
f3b2646a1e | |||
accd6bf3ee | |||
aabcb9cd0b | |||
743c9ebc3c | |||
f8750da593 | |||
d91622551e | |||
9995db128b | |||
f70c507b05 | |||
715d3aed42 | |||
56094094e4 | |||
c406c5bfb5 | |||
c0d126982f | |||
1b7e6aaa75 | |||
729994bd69 | |||
0126669fcf | |||
17d5f3321a | |||
b3c516e6c1 | |||
7546199b38 | |||
4581b18842 | |||
877d246bb5 | |||
db3d13a606 | |||
2308bf7b72 | |||
9915587ada | |||
31381ab310 | |||
e0a2b5991a | |||
224878be45 | |||
ea2cfbc71b | |||
75e377a2db | |||
fc6efda0c2 | |||
5296d03657 | |||
54c09fd553 | |||
6c27ae0efe | |||
320615a6c6 | |||
44059e8498 | |||
d90f748a00 | |||
837af682e2 | |||
fd88e38976 | |||
b3916786c1 | |||
b56a8a8c57 | |||
ff99375ec7 | |||
9b878c442e | |||
607c741d12 | |||
58a6d4c4b4 | |||
dc4315d87b | |||
27b75d1fc8 | |||
|
a99c58df28 | ||
c182c28c15 | |||
0021d41166 | |||
74a03658f9 | |||
ff8adac44c | |||
4ad5ec7f72 | |||
54e6fe2e82 | |||
|
44d1f90774 | ||
|
cc6705ffd6 | ||
|
da69a995e6 | ||
553d25ee56 | |||
c8b1741166 | |||
d8356af421 | |||
b9f604b3c1 | |||
88e8fd7b6a | |||
20acae9135 | |||
aa571e03dc | |||
64a82977ac | |||
70653dcf6e | |||
672cc9e867 | |||
201eb8f79e | |||
115085bb88 |
57
.gitignore
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
################################################################################
|
||||
# Данный GITIGNORE-файл был автоматически создан Microsoft(R) Visual Studio.
|
||||
################################################################################
|
||||
|
||||
/.vs/DAS_2024_1
|
||||
/.vs
|
||||
/aleikin_artem_lab_3/.vs
|
||||
/aleikin_artem_lab_3/ProjectEntityProject/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_3/ProjectEntityProject/obj
|
||||
/aleikin_artem_lab_3/TaskProject/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_3/TaskProject/obj/Container
|
||||
/aleikin_artem_lab_3/TaskProject/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/.vs
|
||||
/aleikin_artem_lab_4/RVIPLab4/Consumer1/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/Consumer1/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/Consumer2/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/Consumer2/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/FirstTutorial/Receive/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/FirstTutorial/Receive/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/FirstTutorial/Send/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/FirstTutorial/Send/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/Publisher/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/Publisher/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/SecondTutorial/NewTask/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/SecondTutorial/NewTask/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/SecondTutorial/Worker/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/SecondTutorial/Worker/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/ThirdTutorial/EmitLog/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/ThirdTutorial/EmitLog/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/ThirdTutorial/ReceiveLogs/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/RVIPLab4/ThirdTutorial/ReceiveLogs/obj
|
||||
/dozorova_alena_lab_2
|
||||
/dozorova_alena_lab_3
|
||||
/dozorova_alena_lab_4
|
||||
/dozorova_alena_lab_5/ConsoleApp1/obj
|
||||
/dozorova_alena_lab_6/ConsoleApp1/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4/RVIPLab4.sln
|
||||
/aleikin_artem_lab_4/.vs
|
||||
/aleikin_artem_lab_4/Consumer1/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/Consumer1/obj
|
||||
/aleikin_artem_lab_4/Consumer2/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/Consumer2/obj
|
||||
/aleikin_artem_lab_4/FirstTutorial/Receive/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/FirstTutorial/Receive/obj
|
||||
/aleikin_artem_lab_4/FirstTutorial/Send/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/FirstTutorial/Send/obj
|
||||
/aleikin_artem_lab_4/Publisher/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/Publisher/obj
|
||||
/aleikin_artem_lab_4/SecondTutorial/NewTask/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/SecondTutorial/NewTask/obj
|
||||
/aleikin_artem_lab_4/SecondTutorial/Worker/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/SecondTutorial/Worker/obj
|
||||
/aleikin_artem_lab_4/ThirdTutorial/EmitLog/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/ThirdTutorial/EmitLog/obj
|
||||
/aleikin_artem_lab_4/ThirdTutorial/ReceiveLogs/bin/Debug/net8.0
|
||||
/aleikin_artem_lab_4/ThirdTutorial/ReceiveLogs/obj
|
||||
/aleikin_artem_lab_4/RVIPLab4.sln
|
16
afanasev_dmitry_lab_4/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Лабораторная работа 4
|
||||
|
||||
## Описание
|
||||
Данная лабораторная работа предназначена для изучения проектирования приложений при помощи брокера сообщений.
|
||||
|
||||
### Уроки из RabbitMQ Tutorials
|
||||
1. ![img.png](images/img1.png)
|
||||
2. ![img.png](images/img2.png)
|
||||
3. ![img.png](images/img3.png)
|
||||
|
||||
### Задание
|
||||
Ссылка на демонстрацию работы программы: https://vk.com/video215756667_456239454?list=ln-IJETwWy23zLuysjetJ
|
||||
|
||||
## Выводы
|
||||
1. Запуск 1 и 2 Consumer'а: Consumer-2 (без задержки) график Queued Messages держится на нуле, в то время как у Consumer-1 график возрастает (скорость обработки сообщений < 1 с).
|
||||
2. Запуск 2 первых Consumer'ов: обрабатывают сообщения последовательно и накапливают очередь.
|
BIN
afanasev_dmitry_lab_4/images/img1.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
afanasev_dmitry_lab_4/images/img2.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
afanasev_dmitry_lab_4/images/img3.png
Normal file
After Width: | Height: | Size: 25 KiB |
38
afanasev_dmitry_lab_4/lesson1/.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
afanasev_dmitry_lab_4/lesson1/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
afanasev_dmitry_lab_4/lesson1/.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
23
afanasev_dmitry_lab_4/lesson1/.idea/misc.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
<option name="theme" value="material" />
|
||||
<option name="button1Title" value="" />
|
||||
<option name="button1Url" value="" />
|
||||
<option name="button2Title" value="" />
|
||||
<option name="button2Url" value="" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
afanasev_dmitry_lab_4/lesson1/.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
afanasev_dmitry_lab_4/lesson1/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
BIN
afanasev_dmitry_lab_4/lesson1/out/ru/ulstu/Main.class
Normal file
BIN
afanasev_dmitry_lab_4/lesson1/out/ru/ulstu/Recv.class
Normal file
BIN
afanasev_dmitry_lab_4/lesson1/out/ru/ulstu/Send.class
Normal file
25
afanasev_dmitry_lab_4/lesson1/pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.ulstu</groupId>
|
||||
<artifactId>lesson1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>amqp-client</artifactId>
|
||||
<version>5.22.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class Recv {
|
||||
private final static String QUEUE_NAME = "hello";
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
factory.setPort(5672);
|
||||
Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel();
|
||||
|
||||
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
||||
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
System.out.println(" [x] Received '" + message + "'");
|
||||
};
|
||||
channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
|
||||
public class Send {
|
||||
private final static String QUEUE_NAME = "hello";
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
factory.setPort(5672);
|
||||
try (Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel()) {
|
||||
|
||||
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
||||
String message = "Hello World!";
|
||||
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
|
||||
System.out.println(" [x] Sent '" + message + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
afanasev_dmitry_lab_4/lesson2/.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
afanasev_dmitry_lab_4/lesson2/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
afanasev_dmitry_lab_4/lesson2/.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
23
afanasev_dmitry_lab_4/lesson2/.idea/misc.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
<option name="theme" value="material" />
|
||||
<option name="button1Title" value="" />
|
||||
<option name="button1Url" value="" />
|
||||
<option name="button2Title" value="" />
|
||||
<option name="button2Url" value="" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
6
afanasev_dmitry_lab_4/lesson2/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
25
afanasev_dmitry_lab_4/lesson2/pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.ulstu</groupId>
|
||||
<artifactId>lesson2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>amqp-client</artifactId>
|
||||
<version>5.22.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.MessageProperties;
|
||||
|
||||
public class NewTask {
|
||||
private static final String TASK_QUEUE_NAME = "task_queue";
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
factory.setPort(5672);
|
||||
try (Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel()) {
|
||||
|
||||
channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null);
|
||||
|
||||
String message = String.join(" ", argv);
|
||||
|
||||
|
||||
channel.basicPublish("", TASK_QUEUE_NAME,
|
||||
MessageProperties.PERSISTENT_TEXT_PLAIN,
|
||||
message.getBytes("UTF-8"));
|
||||
System.out.println(" [x] Sent '" + message + "'");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class Worker {
|
||||
private static final String TASK_QUEUE_NAME = "task_queue";
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
factory.setPort(5672);
|
||||
Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel();
|
||||
|
||||
channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null);
|
||||
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
|
||||
|
||||
int prefetchCount = 1;
|
||||
channel.basicQos(prefetchCount);
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
System.out.println(" [x] Received '" + message + "'");
|
||||
try {
|
||||
doWork(message);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
System.out.println(" [x] Done");
|
||||
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
|
||||
}
|
||||
};
|
||||
|
||||
boolean autoAck = false;
|
||||
channel.basicConsume(TASK_QUEUE_NAME, autoAck, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
|
||||
private static void doWork(String task) throws InterruptedException {
|
||||
for (char ch : task.toCharArray()) {
|
||||
if (ch == '.') Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
38
afanasev_dmitry_lab_4/lesson3/.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
afanasev_dmitry_lab_4/lesson3/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
afanasev_dmitry_lab_4/lesson3/.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
23
afanasev_dmitry_lab_4/lesson3/.idea/misc.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
<option name="theme" value="material" />
|
||||
<option name="button1Title" value="" />
|
||||
<option name="button1Url" value="" />
|
||||
<option name="button2Title" value="" />
|
||||
<option name="button2Url" value="" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
afanasev_dmitry_lab_4/lesson3/.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
afanasev_dmitry_lab_4/lesson3/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
25
afanasev_dmitry_lab_4/lesson3/pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.ulstu</groupId>
|
||||
<artifactId>lesson3</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>amqp-client</artifactId>
|
||||
<version>5.22.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,25 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
|
||||
public class EmitLog {
|
||||
private static final String EXCHANGE_NAME = "logs";
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
factory.setPort(5672);
|
||||
try (Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel()) {
|
||||
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
|
||||
|
||||
String message = argv.length < 1 ? "info: Hello World!" : String.join(" ", argv);
|
||||
|
||||
channel.basicPublish(EXCHANGE_NAME, "", null, message.getBytes("UTF-8"));
|
||||
System.out.println(" [x] Sent '" + message + "'");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class ReceiveLogs {
|
||||
private static final String EXCHANGE_NAME = "logs";
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
factory.setPort(5672);
|
||||
Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel();
|
||||
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
|
||||
|
||||
String queueName = channel.queueDeclare().getQueue();
|
||||
channel.queueBind(queueName, EXCHANGE_NAME, "");
|
||||
|
||||
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
System.out.println(" [x] Received '" + message + "'");
|
||||
};
|
||||
channel.basicConsume(queueName, true, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
38
afanasev_dmitry_lab_4/task/.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
afanasev_dmitry_lab_4/task/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
7
afanasev_dmitry_lab_4/task/.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
23
afanasev_dmitry_lab_4/task/.idea/misc.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
<option name="theme" value="material" />
|
||||
<option name="button1Title" value="" />
|
||||
<option name="button1Url" value="" />
|
||||
<option name="button2Title" value="" />
|
||||
<option name="button2Url" value="" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
afanasev_dmitry_lab_4/task/.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
afanasev_dmitry_lab_4/task/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
25
afanasev_dmitry_lab_4/task/pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.ulstu</groupId>
|
||||
<artifactId>task</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>amqp-client</artifactId>
|
||||
<version>5.22.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,38 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class OrderConsumer1 {
|
||||
private static final String EXCHANGE_NAME = "orders";
|
||||
private static final String QUEUE_NAME = "consumer1_queue";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel();
|
||||
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
|
||||
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
||||
channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "");
|
||||
|
||||
System.out.println(" [*] Consumer 1 ожидает сообщений.");
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
|
||||
System.out.println(" [x] Consumer 1 получил сообщение, обработает через 3 с.: " + message);
|
||||
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
channel.basicConsume(QUEUE_NAME, false, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
|
||||
public class OrderConsumer2 {
|
||||
private static final String EXCHANGE_NAME = "orders";
|
||||
private static final String QUEUE_NAME = "consumer2_queue";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel();
|
||||
|
||||
// Создаём exchange и очередь
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
|
||||
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
|
||||
channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "");
|
||||
|
||||
System.out.println(" [*] Consumer 2 ожидает сообщений.");
|
||||
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
|
||||
System.out.println(" [x] Consumer 2 моментально обработал сообщение: " + message);
|
||||
};
|
||||
channel.basicConsume(QUEUE_NAME, false, deliverCallback, consumerTag -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package ru.ulstu;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
|
||||
public class OrderPublisher {
|
||||
private static final String EXCHANGE_NAME = "orders";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConnectionFactory factory = new ConnectionFactory();
|
||||
factory.setHost("localhost");
|
||||
try (Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel()) {
|
||||
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
|
||||
|
||||
while (true) {
|
||||
String message = "Новый заказ #" + System.currentTimeMillis();
|
||||
channel.basicPublish(EXCHANGE_NAME, "", null, message.getBytes("UTF-8"));
|
||||
System.out.println(" [x] Отправлено сообщение: " + message);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
afanasev_dmitry_lab_5/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Лабораторная работа 5
|
||||
|
||||
## Описание
|
||||
Задание заключается в реализации алгоритмов умножения больших квадратных матриц. Необходимо разработать два алгоритма: последовательный и параллельный. А также провести бенчмарки, а затем описать результаты в отчете.
|
||||
|
||||
**100x100 матрица**:
|
||||
- **4 потока** — наилучший результат.
|
||||
- **10 потоков** — медленнее на почти в половину.
|
||||
- **6 и 8 потоков** — хуже 4 потоков.
|
||||
- **1 и 2 потока** — значительно медленнее.
|
||||
|
||||
**300x300 матрица**:
|
||||
- **4 потока** — лучший результат.
|
||||
- **8 потоков** — чуть хуже.
|
||||
- **10 потоков** — медленнее.
|
||||
- **1 и 2 потока** — значительно медленнее.
|
||||
|
||||
**500x500 матрица**:
|
||||
- **8 потоков** — лучший результат.
|
||||
- **6 и 10 потоков** — немного хуже.
|
||||
- **4 потока** — значительно медленнее.
|
||||
- **1 поток** — самый медленный.
|
||||
|
||||
**Ссылка на демонстрацию работы программы**: https://vk.com/video215756667_456239455?list=ln-z7zFcpvxLexJd3f8ss
|
||||
|
||||
**Вывод**:
|
||||
- Если операция сложнее, рост производительности происходит с увеличением числа потоков.
|
||||
- Слишком много потоков увеличивает накладные расходы (например, 10 потоков). Это может быть связано, например, с:
|
||||
1. **Переключением контекстов**: Когда потоков больше, чем ядер процессора, операционная система часто переключает контексты, что занимает время.
|
||||
2. **Конкуренцией за ресурсы**: Много потоков конкурируют за ограниченные ресурсы, такие как процессорное время и кэш.
|
||||
3. **Управлением потоками**: С увеличением числа потоков растёт нагрузка на систему, связанную с их созданием, управлением и завершением.
|
29
afanasev_dmitry_lab_5/main/.gitignore
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
120
afanasev_dmitry_lab_5/main/src/MatrixMultiplier.java
Normal file
@ -0,0 +1,120 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MatrixMultiplier {
|
||||
private final int[][] matrixA;
|
||||
private final int[][] matrixB;
|
||||
private final int[][] result;
|
||||
private final int size;
|
||||
|
||||
public MatrixMultiplier(int size) {
|
||||
this.size = size;
|
||||
this.matrixA = generateMatrix(size);
|
||||
this.matrixB = generateMatrix(size);
|
||||
this.result = new int[size][size];
|
||||
}
|
||||
|
||||
private int[][] generateMatrix(int size) {
|
||||
int[][] matrix = new int[size][size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int j = 0; j < size; j++) {
|
||||
matrix[i][j] = (int) (Math.random() * 10);
|
||||
}
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public void multiplySequential() {
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int j = 0; j < size; j++) {
|
||||
for (int k = 0; k < size; k++) {
|
||||
result[i][j] += matrixA[i][k] * matrixB[k][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void multiplyParallel(int numThreads) throws InterruptedException {
|
||||
if (numThreads == 1) {
|
||||
multiplySequential();
|
||||
return;
|
||||
}
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(numThreads);
|
||||
int chunkSize = (int) Math.ceil((double) size / numThreads);
|
||||
|
||||
for (int thread = 0; thread < numThreads; thread++) {
|
||||
final int startRow = thread * chunkSize;
|
||||
final int endRow = Math.min(startRow + chunkSize, size);
|
||||
|
||||
executor.submit(() -> {
|
||||
for (int i = startRow; i < endRow; i++) {
|
||||
for (int j = 0; j < size; j++) {
|
||||
for (int k = 0; k < size; k++) {
|
||||
result[i][j] += matrixA[i][k] * matrixB[k][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
|
||||
}
|
||||
|
||||
private void resetResult() {
|
||||
for (int i = 0; i < size; i++) {
|
||||
Arrays.fill(result[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static class Result {
|
||||
int threads;
|
||||
long time;
|
||||
|
||||
Result(int threads, long time) {
|
||||
this.threads = threads;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
int[] matrixSizes = {100, 300, 500};
|
||||
int[] threadCounts = {1, 2, 4, 6, 8, 10};
|
||||
int runs = 5; // количество прогонов
|
||||
|
||||
for (int size : matrixSizes) {
|
||||
System.out.println("\nРазмер матрицы: " + size + "x" + size);
|
||||
MatrixMultiplier multiplier = new MatrixMultiplier(size);
|
||||
List<Result> results = new ArrayList<>();
|
||||
|
||||
for (int threads : threadCounts) {
|
||||
long totalDuration = 0;
|
||||
|
||||
for (int run = 0; run < runs; run++) {
|
||||
multiplier.resetResult();
|
||||
long startTime = System.nanoTime();
|
||||
multiplier.multiplyParallel(threads);
|
||||
long endTime = System.nanoTime();
|
||||
|
||||
totalDuration += (endTime - startTime);
|
||||
}
|
||||
|
||||
long averageDuration = totalDuration / runs;
|
||||
results.add(new Result(threads, averageDuration));
|
||||
}
|
||||
|
||||
// Сортировка по времени выполнения
|
||||
results.sort(Comparator.comparingLong(r -> r.time));
|
||||
|
||||
System.out.println("Результаты (среднее время за " + runs + " прогонов):");
|
||||
for (Result result : results) {
|
||||
System.out.printf("Потоки: %d, среднее время: %d нс\n", result.threads, result.time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
118
afanasev_dmitry_lab_6/FastDeterminantCalculator.java
Normal file
@ -0,0 +1,118 @@
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class FastDeterminantCalculator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] sizes = {100, 300, 500};
|
||||
int[] threads = {1, 4, 8, 10};
|
||||
|
||||
for (int size : sizes) {
|
||||
BigDecimal[][] matrix = generateMatrix(size);
|
||||
for (int threadCount : threads) {
|
||||
long start = System.currentTimeMillis();
|
||||
BigDecimal determinant = calculateDeterminant(matrix, threadCount);
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.printf("Matrix size: %dx%d, Threads: %d, Time: %d ms\n",
|
||||
size, size, threadCount, (end - start));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static BigDecimal[][] generateMatrix(int size) {
|
||||
BigDecimal[][] matrix = new BigDecimal[size][size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
BigDecimal rowSum = BigDecimal.ZERO;
|
||||
for (int j = 0; j < size; j++) {
|
||||
matrix[i][j] = BigDecimal.valueOf(Math.random() * 10);
|
||||
if (i != j) {
|
||||
rowSum = rowSum.add(matrix[i][j]);
|
||||
}
|
||||
}
|
||||
matrix[i][i] = rowSum.add(BigDecimal.valueOf(Math.random() * 10 + 1));
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public static BigDecimal calculateDeterminant(BigDecimal[][] matrix, int threadCount) {
|
||||
int size = matrix.length;
|
||||
BigDecimal[][] lu = new BigDecimal[size][size];
|
||||
int[] permutations = new int[size];
|
||||
ExecutorService executor = Executors.newFixedThreadPool(threadCount);
|
||||
|
||||
if (!luDecomposition(matrix, lu, permutations, executor)) {
|
||||
executor.shutdown();
|
||||
return BigDecimal.ZERO; // Матрица вырожденная
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
|
||||
BigDecimal determinant = BigDecimal.ONE;
|
||||
for (int i = 0; i < size; i++) {
|
||||
determinant = determinant.multiply(lu[i][i]);
|
||||
if (permutations[i] != i) {
|
||||
determinant = determinant.negate(); // Меняем знак при перестановке
|
||||
}
|
||||
}
|
||||
return determinant;
|
||||
}
|
||||
|
||||
public static boolean luDecomposition(BigDecimal[][] matrix, BigDecimal[][] lu, int[] permutations, ExecutorService executor) {
|
||||
int size = matrix.length;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
System.arraycopy(matrix[i], 0, lu[i], 0, size);
|
||||
permutations[i] = i;
|
||||
}
|
||||
|
||||
for (int k = 0; k < size; k++) {
|
||||
int pivot = k;
|
||||
for (int i = k + 1; i < size; i++) {
|
||||
if (lu[i][k].abs().compareTo(lu[pivot][k].abs()) > 0) {
|
||||
pivot = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (lu[pivot][k].abs().compareTo(BigDecimal.valueOf(1e-10)) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pivot != k) {
|
||||
BigDecimal[] temp = lu[k];
|
||||
lu[k] = lu[pivot];
|
||||
lu[pivot] = temp;
|
||||
|
||||
int tempPerm = permutations[k];
|
||||
permutations[k] = permutations[pivot];
|
||||
permutations[pivot] = tempPerm;
|
||||
}
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(size - k - 1);
|
||||
for (int i = k + 1; i < size; i++) {
|
||||
int row = i;
|
||||
int finalK = k;
|
||||
executor.submit(() -> {
|
||||
MathContext mc = new MathContext(20, RoundingMode.HALF_UP);
|
||||
lu[row][finalK] = lu[row][finalK].divide(lu[finalK][finalK], mc);
|
||||
for (int j = finalK + 1; j < size; j++) {
|
||||
lu[row][j] = lu[row][j].subtract(lu[row][finalK].multiply(lu[finalK][j], mc));
|
||||
}
|
||||
latch.countDown();
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
31
afanasev_dmitry_lab_6/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Лабораторная работа 6
|
||||
|
||||
## Описание
|
||||
Задание заключается в реализации алгоритмов нахождения детерминанта квадратной матрицы. Необходимо разработать два алгоритма: последовательный и параллельный. А также провести бенчмарки, а затем описать результаты в отчете.
|
||||
|
||||
**100x100 матрица**:
|
||||
- **8 потоков** — наилучший результат.
|
||||
- **10 потоков** — результат немного хуже.
|
||||
- **4 потока** — примерно такой же результат как на 10 потоках.
|
||||
- **1 поток** — наихудший результат.
|
||||
|
||||
**300x300 матрица**:
|
||||
- **10 потока** — лучший результат.
|
||||
- **8 потоков** — чуть хуже.
|
||||
- **4 потока** — ещё медленее.
|
||||
- **1 поток** — наихудший результат.
|
||||
|
||||
**500x500 матрица**:
|
||||
- **10 потока** — лучший результат.
|
||||
- **8 потоков** — чуть хуже.
|
||||
- **4 потока** — ещё медленее.
|
||||
- **1 поток** — наихудший результат.
|
||||
|
||||
**Ссылка на демонстрацию работы программы**: https://vkvideo.ru/video215756667_456239456?list=ln-W6TTsYuIRdX8ft7ADr
|
||||
|
||||
**Вывод**:
|
||||
- Если операция сложнее, рост производительности происходит с увеличением числа потоков.
|
||||
- Слишком много потоков увеличивает накладные расходы (замтено только на неочень сложных операциях). Это может быть связано, например, с:
|
||||
1. **Переключением контекстов**: Когда потоков больше, чем ядер процессора, операционная система часто переключает контексты, что занимает время.
|
||||
2. **Конкуренцией за ресурсы**: Много потоков конкурируют за ограниченные ресурсы, такие как процессорное время и кэш.
|
||||
3. **Управлением потоками**: С увеличением числа потоков растёт нагрузка на систему, связанную с их созданием, управлением и завершением.
|
13
afanasev_dmitry_lab_7/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
Балансировка нагрузки — это способ распределения запросов между серверами для предотвращения их перегрузки и обеспечения быстродействия системы.
|
||||
Для этого используются алгоритмы, такие как Round Robin, Least Connections, IP Hash.
|
||||
|
||||
Среди популярных открытых технологий — Nginx, HAProxy и Traefik. Nginx часто работает как реверс-прокси,
|
||||
распределяя запросы и обрабатывая SSL. HAProxy подходит для высоконагруженных систем, а Traefik автоматически
|
||||
настраивает маршрутизацию в облачных кластерах.
|
||||
|
||||
В базах данных балансировка нагрузки позволяет направлять запросы на чтение к репликам, а на запись — к основному узлу.
|
||||
Инструменты, такие как ProxySQL, помогают автоматизировать этот процесс.
|
||||
|
||||
Реверс-прокси не только распределяет нагрузку, но и повышает безопасность системы, скрывая её внутреннюю архитектуру.
|
||||
Таким образом, открытые технологии играют ключевую роль в создании масштабируемых и надёжных систем.
|
15
afanasev_dmitry_lab_8/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
Распределённые системы являются основой современных сервисов, включая социальные сети. Их устройство предполагает разделение задач на микросервисы,
|
||||
где каждый компонент выполняет узкоспециализированную функцию. Это упрощает разработку, позволяет масштабировать только необходимые части системы и
|
||||
делает её более устойчивой к сбоям.
|
||||
|
||||
Для управления такими системами используются инструменты оркестрации, например, Kubernetes и Docker Swarm. Они автоматизируют развёртывание,
|
||||
масштабирование и обновление сервисов, упрощая сопровождение. Однако их использование требует опыта и может осложнить отладку.
|
||||
|
||||
Очереди сообщений, такие как RabbitMQ или Kafka, помогают асинхронно передавать данные между сервисами. Это снижает нагрузку и обеспечивает надёжное взаимодействие,
|
||||
передавая запросы, уведомления или данные для обработки.
|
||||
|
||||
Распределённые системы обладают преимуществами в виде масштабируемости, устойчивости и гибкости разработки.
|
||||
Однако их сложность может стать серьёзным вызовом при проектировании и сопровождении.
|
||||
|
||||
Параллельные вычисления полезны, например, для обработки больших объёмов данных или машинного обучения,
|
||||
но в некоторых случаях последовательная обработка более предпочтительна. Такой подход требует анализа задач, чтобы избежать излишней сложности.
|
69
agliullov_daniyar_lab_1/docker-compose.yml
Normal file
@ -0,0 +1,69 @@
|
||||
services:
|
||||
wp_db:
|
||||
|
||||
image: mariadb:10.6.4-focal
|
||||
command: '--default-authentication-plugin=mysql_native_password'
|
||||
volumes:
|
||||
- wp_db_data:/var/lib/mysql
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=somewordpress
|
||||
- MYSQL_DATABASE=wordpress
|
||||
- MYSQL_USER=wordpress
|
||||
- MYSQL_PASSWORD=wordpress
|
||||
expose:
|
||||
- 3306
|
||||
- 33060
|
||||
wordpress:
|
||||
image: wordpress:latest
|
||||
volumes:
|
||||
- wp_data:/var/www/html
|
||||
ports:
|
||||
- 52384:80
|
||||
restart: always
|
||||
environment:
|
||||
- WORDPRESS_DB_HOST=wp_db
|
||||
- WORDPRESS_DB_USER=wordpress
|
||||
- WORDPRESS_DB_PASSWORD=wordpress
|
||||
- WORDPRESS_DB_NAME=wordpress
|
||||
|
||||
db:
|
||||
image: postgres:latest
|
||||
container_name: db
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: 1234
|
||||
POSTGRES_DB: postgres
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql
|
||||
|
||||
redmine:
|
||||
image: redmine:latest
|
||||
container_name: redmine
|
||||
ports:
|
||||
- "11001:3000"
|
||||
environment:
|
||||
- REDMINE_DB_POSTGRESQL=db
|
||||
- REDMINE_DB_DATABASE=redmine
|
||||
- REDMINE_DB_USERNAME=posgres
|
||||
- REDMINE_DB_PASSWORD=1234
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
gitea:
|
||||
image: gitea/gitea:latest
|
||||
container_name: gitea
|
||||
ports:
|
||||
- "11002:3000"
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
volumes:
|
||||
- gitea_data:/data
|
||||
|
||||
volumes:
|
||||
wp_db_data:
|
||||
wp_data:
|
||||
db_data:
|
||||
redmine_db_data:
|
||||
gitea_data:
|
126
agliullov_daniyar_lab_1/readme.md
Normal file
@ -0,0 +1,126 @@
|
||||
▎Лабораторная работа №1 - Знакомство с Docker и Docker Compose
|
||||
|
||||
Цель: Изучение современных технологий контейнеризации.
|
||||
|
||||
▎Задачи:
|
||||
|
||||
1. Установить Docker.
|
||||
|
||||
2. Изучить применение и принципы работы Docker.
|
||||
|
||||
3. Изучить утилиту Docker Compose и структуру файла docker-compose.yml.
|
||||
|
||||
4. Развернуть не менее трех различных сервисов с помощью Docker Compose.
|
||||
|
||||
▎Разворачивание сервисов
|
||||
|
||||
Необходимо развернуть минимум три сервиса из предложенного списка:
|
||||
|
||||
|
||||
1. Redmine - система учета багов (баг-трекер).
|
||||
|
||||
2. WordPress - популярная система управления контентом.
|
||||
|
||||
3. Gitea - сервис для хранения git-репозиториев.
|
||||
|
||||
▎Требования к Docker Compose:
|
||||
|
||||
• Несколько контейнеров.
|
||||
|
||||
• Хотя бы один volume.
|
||||
|
||||
• Хотя бы один проброшенный порт на хост.
|
||||
|
||||
Система должна быть развернута полностью, включая создание администратора и корректное функционирование, что будет подтверждено скриншотами.
|
||||
|
||||
▎Ход работы
|
||||
|
||||
1. Установил Docker Desktop на Windows.
|
||||
|
||||
2. Проверил установку с помощью команды docker --version.
|
||||
|
||||
3. Развернул сервисы (описаны ниже).
|
||||
|
||||
▎Объяснение работы кода:
|
||||
|
||||
▎WordPress:
|
||||
|
||||
1. Образ сборки:
|
||||
image: wordpress:latest - используется последний официальный образ WordPress.
|
||||
|
||||
|
||||
2. Имя контейнера:
|
||||
container_name: wordpress - имя контейнера устанавливается как wordpress.
|
||||
|
||||
|
||||
3. Проброс портов:
|
||||
Порт 80 контейнера пробрасывается на порт 8080 хоста.
|
||||
|
||||
|
||||
4. Тома для хранения данных:
|
||||
|
||||
volumes:
|
||||
- wordpress_data:/var/www/html
|
||||
|
||||
Том wordpress_data монтируется в директорию /var/www/html контейнера для хранения данных WordPress.
|
||||
|
||||
|
||||
5. Переменные окружения для WordPress:
|
||||
|
||||
environment:
|
||||
WORDPRESS_DB_HOST: db
|
||||
WORDPRESS_DB_USER: example_user
|
||||
WORDPRESS_DB_PASSWORD: example_password
|
||||
WORDPRESS_DB_NAME: example_db
|
||||
|
||||
Параметры для подключения к базе данных.
|
||||
|
||||
6. Зависимость от базы данных:
|
||||
depends_on: db - указывает, что WordPress зависит от контейнера базы данных (db).
|
||||
|
||||
▎Redmine:
|
||||
|
||||
1. Образ сборки:
|
||||
image: redmine:latest - используется последний официальный образ Redmine.
|
||||
|
||||
|
||||
2. Имя контейнера:
|
||||
container_name: redmine - имя контейнера устанавливается как redmine.
|
||||
|
||||
|
||||
3. Проброс портов:
|
||||
ports:"8081:3000" - порт 3000 контейнера пробрасывается на порт 8081 хоста.
|
||||
|
||||
|
||||
4. Переменные окружения для Redmine:
|
||||
|
||||
environment:
|
||||
REDMINE_DB_MYSQL: redmine_db
|
||||
REDMINE_DB_USERNAME: redmine_user
|
||||
REDMINE_DB_PASSWORD: redmine_password
|
||||
|
||||
Параметры для подключения к базе данных.
|
||||
|
||||
5. Зависимость от базы данных:
|
||||
depends_on: - redmine_db - Redmine зависит от контейнера с базой данных.
|
||||
|
||||
▎Gitea:
|
||||
|
||||
1. Образ сборки:
|
||||
image: gitea/gitea:latest - используется последний официальный образ Gitea.
|
||||
|
||||
|
||||
2. Имя контейнера:
|
||||
container_name: gitea - имя контейнера устанавливается как gitea.
|
||||
|
||||
|
||||
3. Проброс портов:
|
||||
ports:"8082:3000" - порт 3000 контейнера пробрасывается на порт 8082 хоста.
|
||||
|
||||
|
||||
4. Тома для хранения данных:
|
||||
|
||||
volumes:
|
||||
- gitea_data:/data
|
||||
|
||||
[Видео](https://disk.yandex.ru/d/JFWkukJKwbfhIw)
|
30
aleikin_artem_lab_4/Consumer1/.dockerignore
Normal file
@ -0,0 +1,30 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
17
aleikin_artem_lab_4/Consumer1/Consumer1.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>.</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
aleikin_artem_lab_4/Consumer1/Consumer1.csproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>Container (Dockerfile)</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
28
aleikin_artem_lab_4/Consumer1/Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
# См. статью по ссылке https://aka.ms/customizecontainer, чтобы узнать как настроить контейнер отладки и как Visual Studio использует этот Dockerfile для создания образов для ускорения отладки.
|
||||
|
||||
# Этот этап используется при запуске из VS в быстром режиме (по умолчанию для конфигурации отладки)
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
# Этот этап используется для сборки проекта службы
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Consumer1.csproj", "."]
|
||||
RUN dotnet restore "./Consumer1.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/."
|
||||
RUN dotnet build "./Consumer1.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# Этот этап используется для публикации проекта службы, который будет скопирован на последний этап
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Consumer1.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# Этот этап используется в рабочей среде или при запуске из VS в обычном режиме (по умолчанию, когда конфигурация отладки не используется)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Consumer1.dll"]
|
39
aleikin_artem_lab_4/Consumer1/Program.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory
|
||||
{
|
||||
HostName = "rabbitmq",
|
||||
UserName = "admin",
|
||||
Password = "admin"
|
||||
};
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
var queueName = "slow_queue";
|
||||
var exchangeName = "logs_exchange";
|
||||
await channel.QueueDeclareAsync(queue: queueName, durable: true, exclusive: false, autoDelete: false, arguments: null);
|
||||
|
||||
await channel.QueueBindAsync(queue: queueName, exchange: exchangeName, routingKey: "");
|
||||
|
||||
Console.WriteLine("[Consumer1] Waiting for messages...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
consumer.ReceivedAsync += (model, ea) =>
|
||||
{
|
||||
var body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
Console.WriteLine($"[Consumer1] Received: {message}");
|
||||
|
||||
Thread.Sleep(new Random().Next(2000, 3000));
|
||||
|
||||
Console.WriteLine("[Consumer1] Done processing");
|
||||
channel.BasicAckAsync(deliveryTag: ea.DeliveryTag, multiple: false);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
await channel.BasicConsumeAsync(queue: queueName, autoAck: false, consumer: consumer);
|
||||
}
|
10
aleikin_artem_lab_4/Consumer1/Properties/launchSettings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Consumer1": {
|
||||
"commandName": "Project"
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker"
|
||||
}
|
||||
}
|
||||
}
|
30
aleikin_artem_lab_4/Consumer2/.dockerignore
Normal file
@ -0,0 +1,30 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
17
aleikin_artem_lab_4/Consumer2/Consumer2.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>.</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
aleikin_artem_lab_4/Consumer2/Consumer2.csproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>Container (Dockerfile)</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
28
aleikin_artem_lab_4/Consumer2/Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
# См. статью по ссылке https://aka.ms/customizecontainer, чтобы узнать как настроить контейнер отладки и как Visual Studio использует этот Dockerfile для создания образов для ускорения отладки.
|
||||
|
||||
# Этот этап используется при запуске из VS в быстром режиме (по умолчанию для конфигурации отладки)
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
# Этот этап используется для сборки проекта службы
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Consumer2.csproj", "."]
|
||||
RUN dotnet restore "./Consumer2.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/."
|
||||
RUN dotnet build "./Consumer2.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# Этот этап используется для публикации проекта службы, который будет скопирован на последний этап
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Consumer2.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# Этот этап используется в рабочей среде или при запуске из VS в обычном режиме (по умолчанию, когда конфигурация отладки не используется)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Consumer2.dll"]
|
40
aleikin_artem_lab_4/Consumer2/Program.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
using System.Threading.Channels;
|
||||
|
||||
var factory = new ConnectionFactory
|
||||
{
|
||||
HostName = "rabbitmq",
|
||||
UserName = "admin",
|
||||
Password = "admin"
|
||||
};
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
var queueName = "fast_queue";
|
||||
var exchangeName = "logs_exchange";
|
||||
await channel.QueueDeclareAsync(queue: queueName, durable: true, exclusive: false, autoDelete: false, arguments: null);
|
||||
|
||||
await channel.QueueBindAsync(queue: queueName, exchange: exchangeName, routingKey: "");
|
||||
|
||||
Console.WriteLine("[Consumer2] Waiting for messages...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
consumer.ReceivedAsync += (model, ea) =>
|
||||
{
|
||||
var body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
Console.WriteLine($"[Consumer2] Received: {message}");
|
||||
|
||||
Console.WriteLine("[Consumer2] Done processing");
|
||||
channel.BasicAckAsync(deliveryTag: ea.DeliveryTag, multiple: false);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
await channel.BasicConsumeAsync(queue: queueName, autoAck: false, consumer: consumer);
|
||||
}
|
||||
|
10
aleikin_artem_lab_4/Consumer2/Properties/launchSettings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Consumer2": {
|
||||
"commandName": "Project"
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker"
|
||||
}
|
||||
}
|
||||
}
|
26
aleikin_artem_lab_4/FirstTutorial/Receive/Receive.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory { HostName = "localhost" };
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
await channel.QueueDeclareAsync(queue: "hello", durable: false,
|
||||
exclusive: false, autoDelete: false,arguments: null);
|
||||
|
||||
Console.WriteLine("[*] Waiting for messages...");
|
||||
|
||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
consumer.ReceivedAsync += (model, ea) =>
|
||||
{
|
||||
var body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
Console.WriteLine($" [*] Received {message}");
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
await channel.BasicConsumeAsync("hello", autoAck: true, consumer: consumer);
|
||||
|
||||
Console.WriteLine(" Press [enter] to exit.");
|
||||
Console.ReadLine();
|
14
aleikin_artem_lab_4/FirstTutorial/Receive/Receive.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
18
aleikin_artem_lab_4/FirstTutorial/Send/Send.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using RabbitMQ.Client;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory { HostName = "localhost" };
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
await channel.QueueDeclareAsync(queue: "hello", durable: false,
|
||||
exclusive: false, autoDelete: false, arguments: null);
|
||||
|
||||
const string message = "Hello, World! ~from Artem";
|
||||
var body = Encoding.UTF8.GetBytes(message);
|
||||
|
||||
await channel.BasicPublishAsync(exchange: string.Empty, routingKey: "hello", body: body);
|
||||
Console.WriteLine($" [x] Sent {message}");
|
||||
|
||||
Console.WriteLine(" Press [enter] to exit.");
|
||||
Console.ReadLine();
|
14
aleikin_artem_lab_4/FirstTutorial/Send/Send.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
BIN
aleikin_artem_lab_4/Images/Лаба_Отчет1.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
aleikin_artem_lab_4/Images/Лаба_Отчет2.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
aleikin_artem_lab_4/Images/Лаба_Отчет3.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
aleikin_artem_lab_4/Images/Лаба_Отчет4.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
aleikin_artem_lab_4/Images/Туториал_1.png
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
aleikin_artem_lab_4/Images/Туториал_2.png
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
aleikin_artem_lab_4/Images/Туториал_3.png
Normal file
After Width: | Height: | Size: 69 KiB |
30
aleikin_artem_lab_4/Publisher/.dockerignore
Normal file
@ -0,0 +1,30 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
28
aleikin_artem_lab_4/Publisher/Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
# См. статью по ссылке https://aka.ms/customizecontainer, чтобы узнать как настроить контейнер отладки и как Visual Studio использует этот Dockerfile для создания образов для ускорения отладки.
|
||||
|
||||
# Этот этап используется при запуске из VS в быстром режиме (по умолчанию для конфигурации отладки)
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
# Этот этап используется для сборки проекта службы
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Publisher.csproj", "."]
|
||||
RUN dotnet restore "./Publisher.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/."
|
||||
RUN dotnet build "./Publisher.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# Этот этап используется для публикации проекта службы, который будет скопирован на последний этап
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Publisher.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# Этот этап используется в рабочей среде или при запуске из VS в обычном режиме (по умолчанию, когда конфигурация отладки не используется)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Publisher.dll"]
|
10
aleikin_artem_lab_4/Publisher/Properties/launchSettings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Publisher": {
|
||||
"commandName": "Project"
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker"
|
||||
}
|
||||
}
|
||||
}
|
31
aleikin_artem_lab_4/Publisher/Publisher.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using RabbitMQ.Client;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory
|
||||
{
|
||||
HostName = "rabbitmq",
|
||||
UserName = "admin",
|
||||
Password = "admin"
|
||||
};
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
Console.WriteLine("Connection established.");
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
Console.WriteLine("Channel created.");
|
||||
|
||||
await channel.ExchangeDeclareAsync(exchange: "logs_exchange", type: ExchangeType.Fanout);
|
||||
|
||||
while (true)
|
||||
{
|
||||
var message = $"Event: {GenerateRandomEvent()}";
|
||||
var body = Encoding.UTF8.GetBytes(message);
|
||||
|
||||
await channel.BasicPublishAsync(exchange: "logs_exchange", routingKey: string.Empty, body: body);
|
||||
Console.WriteLine($"[Publisher] Sent: {message}");
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
static string GenerateRandomEvent()
|
||||
{
|
||||
var events = new[] { "Order Received", "User Message", "Create Report" };
|
||||
return events[new Random().Next(events.Length)] + " #" + new Random().Next(0, 99);
|
||||
}
|
17
aleikin_artem_lab_4/Publisher/Publisher.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>.</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
aleikin_artem_lab_4/Publisher/Publisher.csproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>Container (Dockerfile)</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
14
aleikin_artem_lab_4/SecondTutorial/NewTask/NewTask.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
26
aleikin_artem_lab_4/SecondTutorial/NewTask/Program.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using RabbitMQ.Client;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory { HostName = "localhost" };
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
await channel.QueueDeclareAsync(queue: "task_queue", durable: true, exclusive: false,
|
||||
autoDelete: false, arguments: null);
|
||||
|
||||
var message = GetMessage(args);
|
||||
var body = Encoding.UTF8.GetBytes(message);
|
||||
|
||||
var properties = new BasicProperties
|
||||
{
|
||||
Persistent = true
|
||||
};
|
||||
|
||||
await channel.BasicPublishAsync(exchange: string.Empty, routingKey: "task_queue", mandatory: true,
|
||||
basicProperties: properties, body: body);
|
||||
Console.WriteLine($" [x] Sent {message}");
|
||||
|
||||
static string GetMessage(string[] args)
|
||||
{
|
||||
return ((args.Length > 0) ? string.Join(" ", args) : "Hello World!");
|
||||
}
|
35
aleikin_artem_lab_4/SecondTutorial/Worker/Program.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory { HostName = "localhost" };
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
await channel.QueueDeclareAsync(queue: "task_queue", durable: true, exclusive: false,
|
||||
autoDelete: false, arguments: null);
|
||||
|
||||
await channel.BasicQosAsync(prefetchSize: 0, prefetchCount: 1, global: false);
|
||||
|
||||
Console.WriteLine(" [*] Waiting for messages.");
|
||||
|
||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
consumer.ReceivedAsync += async (model, ea) =>
|
||||
{
|
||||
byte[] body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
Console.WriteLine($" [x] Received {message}");
|
||||
|
||||
int dots = message.Split('.').Length - 1;
|
||||
await Task.Delay(dots * 1000);
|
||||
|
||||
Console.WriteLine(" [x] Done");
|
||||
|
||||
// here channel could also be accessed as ((AsyncEventingBasicConsumer)sender).Channel
|
||||
await channel.BasicAckAsync(deliveryTag: ea.DeliveryTag, multiple: false);
|
||||
};
|
||||
|
||||
await channel.BasicConsumeAsync("task_queue", autoAck: false, consumer: consumer);
|
||||
|
||||
Console.WriteLine(" Press [enter] to exit.");
|
||||
Console.ReadLine();
|
14
aleikin_artem_lab_4/SecondTutorial/Worker/Worker.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
21
aleikin_artem_lab_4/ThirdTutorial/EmitLog/EmitLog.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using RabbitMQ.Client;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory { HostName = "localhost" };
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
await channel.ExchangeDeclareAsync(exchange: "logs", type: ExchangeType.Fanout);
|
||||
|
||||
var message = GetMessage(args);
|
||||
var body = Encoding.UTF8.GetBytes(message);
|
||||
await channel.BasicPublishAsync(exchange: "logs", routingKey: string.Empty, body: body);
|
||||
Console.WriteLine($" [x] Sent {message}");
|
||||
|
||||
Console.WriteLine(" Press [enter] to exit.");
|
||||
Console.ReadLine();
|
||||
|
||||
static string GetMessage(string[] args)
|
||||
{
|
||||
return ((args.Length > 0) ? string.Join(" ", args) : "info: Hello World!");
|
||||
}
|
14
aleikin_artem_lab_4/ThirdTutorial/EmitLog/EmitLog.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
31
aleikin_artem_lab_4/ThirdTutorial/ReceiveLogs/ReceiveLogs.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Text;
|
||||
|
||||
var factory = new ConnectionFactory { HostName = "localhost" };
|
||||
using var connection = await factory.CreateConnectionAsync();
|
||||
using var channel = await connection.CreateChannelAsync();
|
||||
|
||||
await channel.ExchangeDeclareAsync(exchange: "logs",
|
||||
type: ExchangeType.Fanout);
|
||||
|
||||
// declare a server-named queue
|
||||
QueueDeclareOk queueDeclareResult = await channel.QueueDeclareAsync();
|
||||
string queueName = queueDeclareResult.QueueName;
|
||||
await channel.QueueBindAsync(queue: queueName, exchange: "logs", routingKey: string.Empty);
|
||||
|
||||
Console.WriteLine(" [*] Waiting for logs.");
|
||||
|
||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
consumer.ReceivedAsync += (model, ea) =>
|
||||
{
|
||||
byte[] body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
Console.WriteLine($" [x] {message}");
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
await channel.BasicConsumeAsync(queueName, autoAck: true, consumer: consumer);
|
||||
|
||||
Console.WriteLine(" Press [enter] to exit.");
|
||||
Console.ReadLine();
|
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
61
aleikin_artem_lab_4/docker-compose.yml
Normal file
@ -0,0 +1,61 @@
|
||||
services:
|
||||
rabbitmq:
|
||||
image: rabbitmq:management
|
||||
container_name: rabbitmq
|
||||
restart: always
|
||||
ports:
|
||||
- "5672:5672"
|
||||
- "15672:15672"
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: admin
|
||||
RABBITMQ_DEFAULT_PASS: admin
|
||||
networks:
|
||||
- my_network
|
||||
|
||||
publisher:
|
||||
build:
|
||||
context: ./Publisher
|
||||
restart: always
|
||||
depends_on:
|
||||
- rabbitmq
|
||||
environment:
|
||||
RABBITMQ_HOST: rabbitmq
|
||||
RABBIT_USERNAME: admin
|
||||
RABBIT_PASSWORD: admin
|
||||
RABBIT_EXCHANGE: 'logs_exchange'
|
||||
networks:
|
||||
- my_network
|
||||
|
||||
consumer1:
|
||||
build:
|
||||
context: ./Consumer1
|
||||
restart: always
|
||||
depends_on:
|
||||
- rabbitmq
|
||||
environment:
|
||||
RABBITMQ_HOST: rabbitmq
|
||||
RABBIT_USERNAME: admin
|
||||
RABBIT_PASSWORD: admin
|
||||
RABBIT_EXCHANGE: 'logs_exchange'
|
||||
RABBIT_QUEUE: 'slow_queue'
|
||||
networks:
|
||||
- my_network
|
||||
|
||||
consumer2:
|
||||
build:
|
||||
context: ./Consumer2
|
||||
restart: always
|
||||
depends_on:
|
||||
- rabbitmq
|
||||
environment:
|
||||
RABBITMQ_HOST: rabbitmq
|
||||
RABBIT_USERNAME: admin
|
||||
RABBIT_PASSWORD: admin
|
||||
RABBIT_EXCHANGE: 'logs_exchange'
|
||||
RABBIT_QUEUE: 'fast_queue'
|
||||
networks:
|
||||
- my_network
|
||||
|
||||
networks:
|
||||
my_network:
|
||||
driver: bridge
|
37
aleikin_artem_lab_4/readme.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Лабораторная работа 4 - Работа с брокером сообщений
|
||||
## ПИбд-42 || Алейкин Артем
|
||||
|
||||
### Описание
|
||||
В данной лабораторной работе мы познакомились с такой утилитой как RabbitMQ.
|
||||
|
||||
### Туториалы
|
||||
1. HelloWorld - Tutorial
|
||||
![Консольный вывод - первый туториал](./Images/Туториал_1.png)
|
||||
|
||||
2. Work Queues - Tutorial
|
||||
![Консольный вывод - второй туториал](./Images/Туториал_2.png)
|
||||
|
||||
3. Publish/Subscribe - Tutorial
|
||||
![Консольный вывод - третий туториал](./Images/Туториал_3.png)
|
||||
|
||||
### Основное задание
|
||||
Было разработано 3 приложения: Publisher, Consumer1 и Consumer2.
|
||||
Первое отвечало за доставку сообщений в очереди. Оно генерирует одно сообщение раз в секунду.
|
||||
Второе и Третье за обработку этих сообщений из очередей, но Consumer1 имел искусственную задержку в 2-3 секунды, в то время как Consumer2 таких ограничений не имел и работу.
|
||||
|
||||
### Шаги для запуска:
|
||||
1. Запуск контейнеров:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
В результате мы можем посмотреть графики по этой ссылке http://localhost:15672/
|
||||
![График Consumer1 - медленный](./Images/Лаба_Отчет2.png)
|
||||
![График Consumer2 - быстрый](./Images/Лаба_Отчет1.png)
|
||||
|
||||
После этого было добавлено еще 3 клиента типа Consumer1 и только после этого их суммарной производительности стало хватать для обработки сообщений.
|
||||
![График Consumer1 для нескольких клиентов - медленный](./Images/Лаба_Отчет3.png)
|
||||
![График Consumer2 - быстрый](./Images/Лаба_Отчет4.png)
|
||||
|
||||
|
||||
Видео демонстрации работы: https://vk.com/video248424990_456239611?list=ln-v0VkWDOiRBxdctENzV
|
10
alkin_ivan_lab_2/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
# .gitignore
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
*.db
|
||||
*.log
|
||||
*.bak
|
||||
*.swp
|
||||
*.swo
|
89
alkin_ivan_lab_2/README.md
Normal file
@ -0,0 +1,89 @@
|
||||
Для выполнения второй лабораторной работы по созданию распределённого приложения с использованием Docker и Docker Compose, давайте разберем все этапы, шаг за шагом. Я предлагаю реализовать вариант программы 1 и программу 2 следующим образом:
|
||||
|
||||
### 1. Вариант программы 1
|
||||
Программа будет искать в каталоге `/var/data` файл с наибольшим количеством строк и перекладывать его в `/var/result/data.txt`.
|
||||
|
||||
### 2. Вариант программы 2
|
||||
Программа будет искать наименьшее число из файла `/var/data/data.txt` и сохранять его третью степень в файл `/var/result/result.txt`.
|
||||
|
||||
### Структура проекта
|
||||
|
||||
1. `moiseev-vv-lab_2/worker-1`: Программа для нахождения файла с наибольшим количеством строк.
|
||||
2. `moiseev-vv-lab_2/worker-2`: Программа для нахождения минимального числа в файле и записи его третьей степени.
|
||||
|
||||
### Шаги реализации:
|
||||
|
||||
#### 1. Реализация программы 1
|
||||
```python
|
||||
|
||||
|
||||
#### 2. Реализация программы 2
|
||||
```python
|
||||
|
||||
|
||||
|
||||
Для обоих приложений создадим Dockerfile. Вот пример для **worker-1**:
|
||||
|
||||
|
||||
|
||||
Пояснение:
|
||||
- **Stage 1**: Мы используем `python:3.10-slim` как образ для сборки, где копируем файл `main.py` и устанавливаем зависимости, если это необходимо.
|
||||
- **Stage 2**: В этом слое мы копируем скомпилированные файлы из предыдущего этапа и определяем команду для запуска приложения.
|
||||
|
||||
Аналогичный Dockerfile будет для **worker-2**.
|
||||
|
||||
### Docker Compose файл
|
||||
|
||||
Теперь нужно настроить файл `docker-compose.yml`, который позволит запустить оба приложения:
|
||||
|
||||
|
||||
|
||||
Пояснение:
|
||||
- **services**: Мы объявляем два сервиса — `worker-1` и `worker-2`.
|
||||
- **build**: Указываем контекст сборки для каждого сервиса (директории, где находятся Dockerfile и код).
|
||||
- **volumes**: Монтируем локальные директории `./data` и `./result` в контейнеры, чтобы обмениваться файлами между сервисами.
|
||||
- **depends_on**: Задаем зависимость `worker-2` от `worker-1`, чтобы второй сервис запускался только после первого.
|
||||
|
||||
### .gitignore
|
||||
|
||||
Для предотвращения попадания ненужных файлов в репозиторий, добавляем файл `.gitignore`. Пример для Python проектов:
|
||||
|
||||
```
|
||||
# .gitignore
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
*.db
|
||||
*.log
|
||||
*.bak
|
||||
*.swp
|
||||
*.swo
|
||||
```
|
||||
|
||||
### Шаги для сборки и запуска
|
||||
|
||||
1. Склонировать репозиторий и перейти в директорию с лабораторной работой:
|
||||
```bash
|
||||
git clone <репозиторий>
|
||||
cd moiseev-vv-lab_2
|
||||
```
|
||||
|
||||
2. Скопировать файлы для `worker-1` и `worker-2` в соответствующие папки.
|
||||
|
||||
3. Создать файл `docker-compose.yml`.
|
||||
|
||||
4. Запустить приложение с помощью команды:
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
5. Проверить вывод, результаты должны быть в директориях `./data` и `./result`.
|
||||
|
||||
### Заключение
|
||||
|
||||
Это пример, как можно реализовать простейшее распределённое приложение с использованием Docker. Первое приложение генерирует данные для второго, который обрабатывает их и записывает результат в файл. Docker и Docker Compose позволяют легко управлять и изолировать каждое приложение.ker Compose для запуска двух программ, обрабатывающих данные в контейнерах.
|
||||
|
||||
## Видео ВК
|
||||
|
||||
https://vkvideo.ru/video150882239_456240341
|
7
alkin_ivan_lab_2/data_generator/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM python:3.9-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . /app
|
||||
|
||||
CMD ["python", "generate_data.py"]
|
29
alkin_ivan_lab_2/data_generator/generate_data.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import random
|
||||
|
||||
|
||||
def generate_random_files(directory, num_files, num_lines_per_file, min_value, max_value):
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
|
||||
for i in range(num_files):
|
||||
file_path = os.path.join(directory, f"file_{i + 1}.txt")
|
||||
with open(file_path, 'w') as f:
|
||||
for _ in range(num_lines_per_file):
|
||||
random_number = random.randint(min_value, max_value)
|
||||
f.write(f"{random_number}\n")
|
||||
print(f"Generated file: {file_path}")
|
||||
|
||||
|
||||
def main():
|
||||
data_directory = '/var/data'
|
||||
num_files = 10
|
||||
num_lines_per_file = 12
|
||||
min_value = 1
|
||||
max_value = 100
|
||||
|
||||
generate_random_files(data_directory, num_files, num_lines_per_file, min_value, max_value)
|
||||
print(f"Generated {num_files} files in {data_directory}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
18
alkin_ivan_lab_2/docker-compose.yml
Normal file
@ -0,0 +1,18 @@
|
||||
# docker-compose.yml
|
||||
|
||||
services:
|
||||
worker-1:
|
||||
build:
|
||||
context: ./worker-1
|
||||
volumes:
|
||||
- ./data:/var/data
|
||||
- ./result:/var/result
|
||||
depends_on:
|
||||
- worker-2
|
||||
|
||||
worker-2:
|
||||
build:
|
||||
context: ./worker-2
|
||||
volumes:
|
||||
- ./data:/var/data
|
||||
- ./result:/var/result
|
14
alkin_ivan_lab_2/worker-1/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
# worker-1/Dockerfile
|
||||
# Stage 1: Build the application
|
||||
FROM python:3.10-slim as builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./main.py .
|
||||
|
||||
# Stage 2: Set up the runtime environment
|
||||
FROM python:3.10-slim
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/main.py .
|
||||
|
||||
CMD ["python", "main.py"]
|
35
alkin_ivan_lab_2/worker-1/main.py
Normal file
@ -0,0 +1,35 @@
|
||||
# worker-1/main.py
|
||||
import os
|
||||
|
||||
|
||||
def find_file_with_most_lines(directory):
|
||||
files = os.listdir(directory)
|
||||
max_lines = 0
|
||||
target_file = None
|
||||
for filename in files:
|
||||
filepath = os.path.join(directory, filename)
|
||||
if os.path.isfile(filepath):
|
||||
with open(filepath, 'r') as file:
|
||||
lines = file.readlines()
|
||||
if len(lines) > max_lines:
|
||||
max_lines = len(lines)
|
||||
target_file = filepath
|
||||
return target_file
|
||||
|
||||
|
||||
def main():
|
||||
source_directory = '/var/data'
|
||||
result_file = '/var/result/data.txt'
|
||||
|
||||
file_to_copy = find_file_with_most_lines(source_directory)
|
||||
|
||||
if file_to_copy:
|
||||
with open(file_to_copy, 'r') as source, open(result_file, 'w') as dest:
|
||||
dest.writelines(source.readlines())
|
||||
print(f"File with the most lines: {file_to_copy} copied to {result_file}")
|
||||
else:
|
||||
print("No files found in the source directory.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
14
alkin_ivan_lab_2/worker-2/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
# worker-1/Dockerfile
|
||||
# Stage 1: Build the application
|
||||
FROM python:3.10-slim as builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./main.py .
|
||||
|
||||
# Stage 2: Set up the runtime environment
|
||||
FROM python:3.10-slim
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/main.py .
|
||||
|
||||
CMD ["python", "main.py"]
|