SlideShare a Scribd company logo
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com1
Akka-http
Open Access Quality Assurance & Related Software Development for Financial Markets
Tel: +7 495 640 2460, +1 415 830 38 49
www.exactpro.com
Дата 20.02.2017
Автор Антон Ситников
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com2
Дневник успеваемости
Понедельник
Математика
Физика
Литература 4
Физическая культура
Вторник
Русский язык 2
Математика
Английский язык 5
Технология
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com3
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com4
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Ractive.js REST / JSON
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com5
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Ractive.js REST / JSON
SQL Server
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com6
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com7
Web-сервис
HTTP backend
Сервис
данных
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com8
Web-сервис
akka-http akka JSON
HTTP backend
Сервис
данных
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com9
Сервис данных
Студенты Расписание Предметы
Оценки
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com10
01 public class ScheduleActor extends AbstractActor {
02
03 public ScheduleActor() {
04 receive(ReceiveBuilder
05 .match(SetSchedule.class,
06 command -> this.setSchedule(command.getGroupSchedules()))
07 .match(GetSchedule.class,
08 command -> this.getSchedule(command.getGroupId()))
09 .build());
10 }
11 }
ScheduleActor
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com11
01 private final Map<Integer, Schedule> groupSchedules
02 = new HashMap<>();
03
04 private void setSchedule(final List<Schedule> groupSchedules) {
05 this.groupSchedules.clear();
06 groupSchedules.forEach(schedule ->
07 this.groupSchedules.put(schedule.getGroupId(), schedule));
08 }
09
10 private void getSchedule(final int groupId) {
11 this.sender().tell(
12 this.groupSchedules.get(groupId), this.self());
13 }
14 }
ScheduleActor
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com12
SetSchedule
01 import static java.util.Collections.unmodifiableList;
02
03 public class SetSchedule {
04 private final List<Schedule> groupSchedules;
05
06 public SetSchedule(final List<Schedule> groupSchedules) {
07 this.groupSchedules = unmodifiableList(groupSchedules);
08 }
09
10 public List<Schedule> getGroupSchedules() {
11 return this.groupSchedules;
12 }
13 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com13
Данные
Студенты Расписание Предметы
Оценки
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com14
Markbook actor
MarkbookActor StudentsActor ScheduleActor SubjectsActor
GetStudent
Student
GetSchedule
Schedule
GetSubjects
List<Subjects>
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com15
Markbook actor
MarkbookActor StudentsActor ScheduleActor SubjectsActor
GetStudent
Student
GetStudent
Student
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com16
Child workers
Родитель
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com17
Child workers
Родитель
Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com18
Child workers
Родитель
Ребенок Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com19
Child workers
Родитель
Ребенок Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com20
Child workers
Родитель
Ребенок Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com21
Markbook worker actor
WorkerActor StudentsActor ScheduleActor SubjectsActor
GetStudent
Student
GetSchedule
Schedule
GetSubjects
List<Subjects>
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com22
Child workers
Markbook
Worker
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com23
Markbook actor
WorkerActor StudentsActor ScheduleActor SubjectsActor
Set<Marks>
GetMarks
GetSchedule
Schedule
GetSubjects
List<Subjects>
Markbook
GetStudentMarks
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com24
Markbook worker actor
01 private static class WorkerActor extends AbstractActor {
02
03 public WorkerActor() {
04 receive(ReceiveBuilder
05 .match(GetStudentWeekMarks.class,
06 command -> this.start(
07 command.getStudentId(), command.getWeekNumber()))
08 .match(Student.class,
09 student -> this.processStudent(student))
10 .match(Schedule.class,
11 schedule -> this.processSchedule(schedule))
12 .match(SortedMap.class,
13 marks -> this.processMarks(marks))
14 .match(List.class,
15 subjects -> this.processSubjects(subjects))
16 .build());
17 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com25
Markbook worker actor
01 private void processSchedule(final Schedule schedule) {
02 this.schedule = schedule;
03 final HashSet<Integer> subjectIds = new HashSet<>();
04 schedule.getDays().forEach(
05 daySchedule -> subjectIds.addAll(daySchedule.getSubjectIds()));
06 this.context().actorSelection("/user/subjects").tell(
07 new GetSubjects(subjectIds), this.self());
08 this.context().actorSelection("..").tell(
09 new GetStudentWeekMarks(this.studentId, this.weekNumber),
10 this.self());
11 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com26
Markbook worker actor
01 private void processMarks(final SortedMap<MarkKey, Integer> marks) {
02 this.marks = marks;
03 this.replyIfReady();
04 }
05
06 private void replyIfReady() {
07 if ((this.marks != null) && (this.subjectIndex != null)) {
08 this.receiver.tell(unmodifiableList(this.getWeekMarks()),
09 this.self());
10 this.self().tell(PoisonPill.getInstance(), this.self());
11 }
12 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com27
REST API
/api/students
/api/students/studentId/marks/weekNumber
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com28
routing
01 private Route apiRoute() {
02 return pathPrefix("students", () ->
03 route(
04 rawPathPrefix(pathEnd(), () ->
05 onSuccess(() -> toJava(Patterns.ask(
06 this.studentStore, ListStudents.instance(), TIMEOUT)),
07 students -> complete(
08 StatusCodes.OK, students, Jackson.marshaller())
09 )
10 ),
11 path(
12 // ...
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com29
routing
01 path(
studentId
02 integerSegment().slash(segment("marks")
weekNumber
03 .slash(integerSegment())),
04 (studentId, weekNumber) ->
05 onSuccess(
06 () -> toJava(Patterns.ask(
07 this.markbook,
08 new GetStudentWeekMarks(studentId, weekNumber), TIMEOUT)),
09 weekMarks -> complete(
10 StatusCodes.OK, weekMarks, Jackson.marshaller())
11 )
12 )
13 )
14 );
15 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com30
routing
01 private Route appRoute() {
02 return route(
03 staticRoute(),
04 pathPrefix("api", () -> apiRoute())
05 );
06 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com31
Запуск сервера
01 private void initializeServer() {
02 final ActorMaterializer materializer
03 = ActorMaterializer.create(this.system);
04 final ConnectHttp host = ConnectHttp.toHost("127.0.0.1");
05 Http.get(this.system).bindAndHandle(
06 appRoute().flow(this.system, materializer),
07 host, materializer);
08 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com32
Спасибо

More Related Content

PPTX
Akka HTTP
PPTX
Using Cluster Analysis for Characteristics Detection in Software Defect Reports
PPT
QA management at Exactpro (5)
PPT
EXTENT-2016: Managing QA for Complex Systems in Agile Development Framework
PDF
Верификация технологических платформ Лондонской фондовой биржи
PPT
Innovation in Quality Assurance – What is the Impact on Trading technology?
PDF
ここまでできる!Salesforce Connect 最新機能 (Winter'17) のご紹介
PDF
Introduction to Developing Android Apps With the Salesforce Mobile SDK
Akka HTTP
Using Cluster Analysis for Characteristics Detection in Software Defect Reports
QA management at Exactpro (5)
EXTENT-2016: Managing QA for Complex Systems in Agile Development Framework
Верификация технологических платформ Лондонской фондовой биржи
Innovation in Quality Assurance – What is the Impact on Trading technology?
ここまでできる!Salesforce Connect 最新機能 (Winter'17) のご紹介
Introduction to Developing Android Apps With the Salesforce Mobile SDK

Similar to Akka-http (20)

PDF
Salesforce platform session 2
PDF
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
PPTX
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
PPT
Non-Functional Testing at London Stock Exchange
DOC
Rathna Arun Solomon_BA
PDF
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
PDF
Quickly Create Data Sets for the Analytics Cloud
PPTX
Exactpro: Non-functional testing approach
PPT
9 Characteristics of Agile Methodologies to Turbo-charge Your Testing by Rex ...
PDF
Visartech Company Profile
PDF
Silvertouch Profile
PPTX
Hca advanced developer workshop
PDF
Eland: A Python client for data analysis and exploration
PPTX
Boston 16 03
PDF
Ortus Government.pdf
PPTX
Introduction to the Wave Platform API
PDF
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
PDF
Resume
PDF
Nestle Quick Wins Digital Commerce Conversion Workshop
PDF
From Force.com to Heroku and Back
Salesforce platform session 2
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Non-Functional Testing at London Stock Exchange
Rathna Arun Solomon_BA
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
Quickly Create Data Sets for the Analytics Cloud
Exactpro: Non-functional testing approach
9 Characteristics of Agile Methodologies to Turbo-charge Your Testing by Rex ...
Visartech Company Profile
Silvertouch Profile
Hca advanced developer workshop
Eland: A Python client for data analysis and exploration
Boston 16 03
Ortus Government.pdf
Introduction to the Wave Platform API
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
Resume
Nestle Quick Wins Digital Commerce Conversion Workshop
From Force.com to Heroku and Back
Ad

More from Iosif Itkin (20)

PDF
Foundations of Software Testing Lecture 4
PPTX
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
PDF
Exactpro FinTech Webinar - Global Exchanges Test Oracles
PDF
Exactpro FinTech Webinar - Global Exchanges FIX Protocol
PDF
Operational Resilience in Financial Market Infrastructures
PDF
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
PDF
Testing the Intelligence of your AI
PDF
EXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
PDF
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
PPTX
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
PDF
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
PDF
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
PPTX
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
PDF
QA Community Saratov: Past, Present, Future (2019-02-08)
PDF
Machine Learning and RoboCop Testing
PDF
Behaviour Driven Development: Oltre i limiti del possibile
PDF
2018 - Exactpro Year in Review
PPTX
Exactpro Discussion about Joy and Strategy
PPTX
FIX EMEA Conference 2018 - Post Trade Software Testing Challenges
PDF
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
Foundations of Software Testing Lecture 4
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
Exactpro FinTech Webinar - Global Exchanges Test Oracles
Exactpro FinTech Webinar - Global Exchanges FIX Protocol
Operational Resilience in Financial Market Infrastructures
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
Testing the Intelligence of your AI
EXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
QA Community Saratov: Past, Present, Future (2019-02-08)
Machine Learning and RoboCop Testing
Behaviour Driven Development: Oltre i limiti del possibile
2018 - Exactpro Year in Review
Exactpro Discussion about Joy and Strategy
FIX EMEA Conference 2018 - Post Trade Software Testing Challenges
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
Ad

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Approach and Philosophy of On baking technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Big Data Technologies - Introduction.pptx
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
KodekX | Application Modernization Development
NewMind AI Monthly Chronicles - July 2025
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Approach and Philosophy of On baking technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
GamePlan Trading System Review: Professional Trader's Honest Take
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

Akka-http

  • 1. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com1 Akka-http Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 2460, +1 415 830 38 49 www.exactpro.com Дата 20.02.2017 Автор Антон Ситников
  • 2. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com2 Дневник успеваемости Понедельник Математика Физика Литература 4 Физическая культура Вторник Русский язык 2 Математика Английский язык 5 Технология
  • 3. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com3 Наше приложение Single-page web application ДанныеWeb-сервис
  • 4. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com4 Наше приложение Single-page web application ДанныеWeb-сервис Ractive.js REST / JSON
  • 5. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com5 Наше приложение Single-page web application ДанныеWeb-сервис Ractive.js REST / JSON SQL Server
  • 6. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com6 Наше приложение Single-page web application ДанныеWeb-сервис
  • 7. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com7 Web-сервис HTTP backend Сервис данных
  • 8. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com8 Web-сервис akka-http akka JSON HTTP backend Сервис данных
  • 9. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com9 Сервис данных Студенты Расписание Предметы Оценки
  • 10. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com10 01 public class ScheduleActor extends AbstractActor { 02 03 public ScheduleActor() { 04 receive(ReceiveBuilder 05 .match(SetSchedule.class, 06 command -> this.setSchedule(command.getGroupSchedules())) 07 .match(GetSchedule.class, 08 command -> this.getSchedule(command.getGroupId())) 09 .build()); 10 } 11 } ScheduleActor
  • 11. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com11 01 private final Map<Integer, Schedule> groupSchedules 02 = new HashMap<>(); 03 04 private void setSchedule(final List<Schedule> groupSchedules) { 05 this.groupSchedules.clear(); 06 groupSchedules.forEach(schedule -> 07 this.groupSchedules.put(schedule.getGroupId(), schedule)); 08 } 09 10 private void getSchedule(final int groupId) { 11 this.sender().tell( 12 this.groupSchedules.get(groupId), this.self()); 13 } 14 } ScheduleActor
  • 12. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com12 SetSchedule 01 import static java.util.Collections.unmodifiableList; 02 03 public class SetSchedule { 04 private final List<Schedule> groupSchedules; 05 06 public SetSchedule(final List<Schedule> groupSchedules) { 07 this.groupSchedules = unmodifiableList(groupSchedules); 08 } 09 10 public List<Schedule> getGroupSchedules() { 11 return this.groupSchedules; 12 } 13 }
  • 13. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com13 Данные Студенты Расписание Предметы Оценки
  • 14. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com14 Markbook actor MarkbookActor StudentsActor ScheduleActor SubjectsActor GetStudent Student GetSchedule Schedule GetSubjects List<Subjects>
  • 15. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com15 Markbook actor MarkbookActor StudentsActor ScheduleActor SubjectsActor GetStudent Student GetStudent Student
  • 16. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com16 Child workers Родитель
  • 17. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com17 Child workers Родитель Ребенок
  • 18. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com18 Child workers Родитель Ребенок Ребенок
  • 19. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com19 Child workers Родитель Ребенок Ребенок
  • 20. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com20 Child workers Родитель Ребенок Ребенок
  • 21. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com21 Markbook worker actor WorkerActor StudentsActor ScheduleActor SubjectsActor GetStudent Student GetSchedule Schedule GetSubjects List<Subjects>
  • 22. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com22 Child workers Markbook Worker
  • 23. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com23 Markbook actor WorkerActor StudentsActor ScheduleActor SubjectsActor Set<Marks> GetMarks GetSchedule Schedule GetSubjects List<Subjects> Markbook GetStudentMarks
  • 24. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com24 Markbook worker actor 01 private static class WorkerActor extends AbstractActor { 02 03 public WorkerActor() { 04 receive(ReceiveBuilder 05 .match(GetStudentWeekMarks.class, 06 command -> this.start( 07 command.getStudentId(), command.getWeekNumber())) 08 .match(Student.class, 09 student -> this.processStudent(student)) 10 .match(Schedule.class, 11 schedule -> this.processSchedule(schedule)) 12 .match(SortedMap.class, 13 marks -> this.processMarks(marks)) 14 .match(List.class, 15 subjects -> this.processSubjects(subjects)) 16 .build()); 17 }
  • 25. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com25 Markbook worker actor 01 private void processSchedule(final Schedule schedule) { 02 this.schedule = schedule; 03 final HashSet<Integer> subjectIds = new HashSet<>(); 04 schedule.getDays().forEach( 05 daySchedule -> subjectIds.addAll(daySchedule.getSubjectIds())); 06 this.context().actorSelection("/user/subjects").tell( 07 new GetSubjects(subjectIds), this.self()); 08 this.context().actorSelection("..").tell( 09 new GetStudentWeekMarks(this.studentId, this.weekNumber), 10 this.self()); 11 }
  • 26. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com26 Markbook worker actor 01 private void processMarks(final SortedMap<MarkKey, Integer> marks) { 02 this.marks = marks; 03 this.replyIfReady(); 04 } 05 06 private void replyIfReady() { 07 if ((this.marks != null) && (this.subjectIndex != null)) { 08 this.receiver.tell(unmodifiableList(this.getWeekMarks()), 09 this.self()); 10 this.self().tell(PoisonPill.getInstance(), this.self()); 11 } 12 }
  • 27. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com27 REST API /api/students /api/students/studentId/marks/weekNumber
  • 28. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com28 routing 01 private Route apiRoute() { 02 return pathPrefix("students", () -> 03 route( 04 rawPathPrefix(pathEnd(), () -> 05 onSuccess(() -> toJava(Patterns.ask( 06 this.studentStore, ListStudents.instance(), TIMEOUT)), 07 students -> complete( 08 StatusCodes.OK, students, Jackson.marshaller()) 09 ) 10 ), 11 path( 12 // ...
  • 29. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com29 routing 01 path( studentId 02 integerSegment().slash(segment("marks") weekNumber 03 .slash(integerSegment())), 04 (studentId, weekNumber) -> 05 onSuccess( 06 () -> toJava(Patterns.ask( 07 this.markbook, 08 new GetStudentWeekMarks(studentId, weekNumber), TIMEOUT)), 09 weekMarks -> complete( 10 StatusCodes.OK, weekMarks, Jackson.marshaller()) 11 ) 12 ) 13 ) 14 ); 15 }
  • 30. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com30 routing 01 private Route appRoute() { 02 return route( 03 staticRoute(), 04 pathPrefix("api", () -> apiRoute()) 05 ); 06 }
  • 31. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com31 Запуск сервера 01 private void initializeServer() { 02 final ActorMaterializer materializer 03 = ActorMaterializer.create(this.system); 04 final ConnectHttp host = ConnectHttp.toHost("127.0.0.1"); 05 Http.get(this.system).bindAndHandle( 06 appRoute().flow(this.system, materializer), 07 host, materializer); 08 }
  • 32. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com32 Спасибо