Professional Documents
Culture Documents
Midterm Review PDF
Midterm Review PDF
ESB
3
LESSON 1
Client 1 Server 1
Load
Server 1
Failover client
Load
balancer
Server 2
What does failover solve?
Server 1 1 Call method 1 Server 1
1 Call method 1
Call method 1 Load Call method 1 Load
client client balancer
balancer
Server 2 Server 2
3 Server 1
Call method 2
Load Call method 2
client
balancer
Server 2
Failover reduces the change on errors, but
cannot prevent all errors
10
LESSON 2
Client
Layering
Minimal functioning core
Microkernel
Pipe-and-Filter
master
Master-Slave
DI +save()
+load()
+update()
+delete()
+findByName()
DI JMSSender
+sendJMSMessage()
Browser Server DB
+addCustomer() +sendEmail()
SpringBootApplication
CustomerServiceImpl EmailServiceImpl
+addCustomer() +sendEmail()
1 : addCustomer()
2 : sendEmail()
@Service
public class EmailServiceImpl implements EmailService{
public void sendEmail() {
System.out.println("Sending email");
}
}
@Service
public class CustomerServiceImpl implements CustomerService{
@Autowired
private EmailService emailService; Inject the EmailService in the
CustomerService
public void addCustomer() {
emailService.sendEmail();
}
}
© 2018 ICT Intelligence 23
REST
@RestController
public class ContactController {
@RequestMapping("/contact/{firstName}")
public ResponseEntity<?> getContact(@PathVariable String firstName) {
Contact contact = contacts.get(firstName);
if (contact == null) {
return new ResponseEntity<CustomErrorType>(new CustomErrorType("Contact with firstname= "
+ firstName + " is not available"),HttpStatus.NOT_FOUND);
}
return new ResponseEntity<Contact>(contact, HttpStatus.OK);
}
@RequestMapping(value="/contact", method=RequestMethod.POST)
public ResponseEntity<?> addContact(@RequestBody Contact contact) {
contacts.put(contact.getFirstName(), contact);
return new ResponseEntity<Contact>(contact, HttpStatus.OK);
}
application.properties
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=testdb
Customer
Package
+CustomerId
+trackingNumber
+firstName
+weight
+lastName
+type
+email
+phone
Product
+productNumber
+name
+price
Address
Money
-street
-city -amount
-zip -currency
+computeDistance(Address a) +add(Money m)
+equals(Address a) +subtract(Money m)
+equals(Money m)
Weight
Review Dimension
-value
-nrOfStars -unit -length
-description -width
+add(Weigth w) -heigth
+subtract(Weigth w)
+equals(Weigth w) +add(Dimension d)
+subtract(Dimentsion d)
+equals(Dimension d)
2. Enhancing explicitness
What is colorCode?
Shape
What is the allowed range?
+String colorCode
<<entity>>
Customer
+customerNumber <<value object>>
-firstName Contact
-lastName -email
-email -phone
-phone 1 <<value object>>
+validate()
Address
-street
<<entity>> -street
-city Customer -city
-zip -zip
+customerNumber
-state -firstName 1 -state
-country -lastName -country
-userName +validate()
<<value object>> 1
-password +computeDistance(Address a)
Login
+validateEmail() +userName
+validatePhone() +password
+validateAddress() +validate()
+validateLogin() +check()
+checkUserNameAndPassword()
+computeDistance()
ShippingCostCalculator
+calculateCostToShip(Package package)
DeliveryFailed
OrderReceived
+sender
+orderNumber
+receiver
+message
<<value object>>
Address
+street
+city 1
+zip
<<aggregate root>> <<aggregate root>> <<value object>> <<value object>>
Customer Account AccountEntry amount Money
+customerId +date 1 +amount
+accountNumber *
+firstName +description +currency
+customerId
<<value object>> 1 +lastName
Contact
+email
+phone
<<value object>>
Location
+building <<aggregate root>> <<value object>>
prerequisites CourseSchedule
+roomNumber 0..* Course
1
+scheduleId +courseNumber
<<aggregate root>> +creationDate *
Course +name
+status
+courseNumber +studentId
+name
* +departmentName
StudentReview
+status
+description
@Bean
RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
return restTemplate;
}
Products
Product
ProductService
+name
+getProduct(productNumber) +productNumber
+findProduct() +price
+addProduct() +description
ProductDTO
Both the ProductService and
+productNumber
the ShoppingService depend
+name only on the ProductDTO
+price
Shopping
Product
ShoppingService +productNumber
+name
+addProduct(Product) +price
@Service
public class Listener { Listen to AddCustomer events
@EventListener
public void onEvent(AddCustomerEvent event) {
System.out.println("received event :" + event.getMessage());;
}
}
JVM JVM
Messaging
middleware
Object A Object B
Person
application.properties
spring.activemq.broker-url=tcp://localhost:61616
spring.activemq.user=admin
spring.activemq.password=admin
@JmsListener(destination = "testQueue")
public void receiveMessage(final Person person) {
System.out.println("JMS receiver received message:" + person.getFirstName()+"
"+person.getLastName());
}
}
component component
Integration
component component
broker
component component
DB
Process
orchestration
ESB
DB DB DB DB
Application
ESB
Spring
beans