-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use restTemplate #44
Merged
Merged
use restTemplate #44
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A new POJO named 'Customer' has been added to the project. This class holds a unique identifier for each customer, represented as a UUID. This addition will contribute to handling customer's essential data in the system.
CustomerDetail POJO has been added which includes customer's UUID, first name, and last name. This file will assist in recording key details of a customer and ensure easier data management.
Created a new class, FakeDatabaseComponent, to simulate and manage customer data in the system. It generates lists of randomly generated Customer and CustomerDetail objects on initialization. The goal is to test and simulate the behaviour of the system with production-like data.
Added a new plain old Java object (POJO) known as Customer. This class features a constructor and a getter method for identifier, which is represented by UUID.
Added the FakeDatabaseComponent to the MainController class. This component was initialized in MainController's constructor and made available for further use. This can aid in mocking interactions with the database.
Added a Logger instance to FakeDatabaseComponent for better tracking. Simplified three code blocks into simpler segments for better readability. The Logger instance helps trace customer and customer detail addition, improving debugging process.
…s diff, the correct commit message would be: Add 'detailsId' field to 'Customer' class A new field 'detailsId' has been added to 'Customer' class, along with it's getter method. The constructor has also been modified to initialize the 'detailsId'. It will help to link the 'Customer' object with corresponding 'details' object for better object structure and future queries.
A new field 'detailsId' has been added to 'Customer' class, along with its getter method. The constructor has also been modified to initialize the 'detailsId'. This will help to link the 'Customer' object with the corresponding 'details' object for better object structure and future queries.
A new method 'getCustomer' has been added to the MainController. This method uses HTTP GET to retrieve the customer data by UUID from the fake database. This enhancement provides more detailed access to the individual customer records stored in the system.
A new method 'getCustomerDetail' has been introduced in the MainController. The method utilizes an HTTP GET request to fetch specific customer's detail with a specific UUID from the 'fakeDatabaseComponent'. This code change allows detailed information access for individual customers.
The FakeDatabaseComponent class has been refactored to update how it adds customers and their details info into the database. A unique UUID is now applied for each new customer and their details, improving data tracking and access efficiency.
Created a new POJO class, ResponseMessage, in the consumer package of the messaging service. This class encapsulates the structure of a standard response message, containing a response code, a message, and a results field with a generic data type.
Constructed a new RestTemplateConfiguration class within the consumer section of the event sourcing microservices. This class is for setup configurations required for making HTTP requests using RestTemplate, made available through a Bean annotation.
Added the @ConfigurationPropertiesScan annotation to the EventSourcingServiceConsumerApplication class. This means that from now on, properties files within the specified package will be automatically scanned and processed. This avoids the need to manually define each configuration property bean.
The ConnectionConfiguration.java file has been added to the EventSourcingServiceConsumer package. This file includes a friendService field with corresponding getter and setter. Now, the application will be able to retrieve configuration for the "connection" prefix from the properties file.
A connection property for 'friend-service' has been added in application properties of the EventSourcingServiceConsumer. This is crucial in allowing the application to retrieve the "connection" prefix from the properties file, thus ensuring better interaction between the services.
The ConnectionConfiguration class now includes the 'ConfigurationPropertiesScan' annotation. This enhancement allows Spring Boot to scan for classes marked with the 'ConfigurationProperties' annotation. In this case, it enables the retrieval of 'friendService' connection properties, thereby improving the interaction between microservices.
RestTemplate dependency has been injected into MainController through the constructor. This allows for programmatic HTTP access from within the application, subsequently enabling the interaction with remote RESTful services.
A friendIp dependency has been introduced into MainController along with RestTemplate. The friendIp value is fetched from the configuration using @value annotation. This enables the configuration of the IP address of the "friend-service" at runtime.
Added two new endpoints to MainController to fetch customer and customer details. These endpoints makes a GET request to the friend service using its IP and UUID path. This provides the capability to retrieve individual customer and their detailed information.
The commit adds a necessary environment variable check in the entrypoint.sh of the messaging consumer. It checks if the "FRIEND_IP" variable has been defined, and raises an error message if it is not, improving the robustness of the application configuration process.
The added FRIEND_IP variable in the consumer-vars environment file ensures the correct configuration of the messaging consumer. This addition can improve communication between components in the system and enhance the overall robustness of the application configuration process.
The images for both producer_0 and consumer_0 in the compose.yaml file were updated from event-sourcing to messaging. This change was made to reflect the switch to a messaging framework from an event sourcing one, improving the system's stability and efficiency.
An ObjectMapper was incorporated into the FakeDatabaseComponent. The addition also necessitated the creation of an accommodating new constructor. This change stands to improve our application’s functionality by allowing for the more flexible and efficient manipulation of JSON data.
The logging methodology of FakeDatabaseComponent has been improved by the addition of serialization. The ObjectMapper is now utilized to serialize the customerFake object before logging. This change enhances the readability of the logs and provides better visualization of the customer data. In case the serialization fails, a runtime exception is thrown.
The 'FRIEND_IP' in the consumer environment file has been updated to include a URL and port, rather than just a service name. This change means that connections can now be made directly via the specified URL and port, rather than through service discovery.
A default logging level has been added to the application.properties file in the consumer environment. The new line `logging.level.root` is assigned a default value of 'INFO' if no `LOG_LEVEL` is specified, providing a granular control over the verbosity of logging output.
The comparison for customer UUID in the getCustomer and getCustomerDetail methods has been updated. Rather than using a simple equality operator, we now use the compareTo method to properly compare the UUID objects. This is to ensure the correct customer or customer detail is fetched.
The IP port of the friend service has been updated in the consumer-vars.env configuration file. This was changed from 1001 to 8080 to correct errors experienced when the consumer tried to connect to the friend service.
Implemented a new class `CustomerDetailsParameterizedTypeReference` that extends `ParameterizedTypeReference`. This class specifically handles the `ResponseMessage<CustomerDetail>` type making it easier to work with such types in the application.
Introduced a new class, CustomerParameterizedTypeReference, in the utils package. This class, which extends the ParameterizedTypeReference class, specifically handles the ResponseMessage<Customer> type, aiming to simplify the management of such types in the application.
The "getCustomer" and "getCustomerDetail" methods in MainController have been refactored to use the restTemplate's exchange() method together with ParameterizedTypeReference. This change enhances type safety when consuming REST APIs and simplifies the handling of ResponseMessage<Customer> and ResponseMessage<CustomerDetail> types in these methods.
A public constructor has been added to the class CustomerDetailsParameterizedTypeReference that extends from ParameterizedTypeReference. This modification enhances the initialization of the class and increases the efficiency and type safety when handling customer details.
The class CustomerParameterizedTypeReference, which extends ParameterizedTypeReference, now has a public constructor. The addition enhances class initialization and promotes efficient, type-safe handling of customer details.
Initialized ObjectMapper in MainController's constructor to allow easy mapping and parsing of JSON data. This change will improve data handling and conversion within the MainController.java file.
Modified getCustomer method in MainController.java to improve logging of responses. It now includes a detailed debug log of each response from REST template exchange, with error handling for JSON processing exceptions.
Two libraries, `com.fasterxml.jackson.core.JsonProcessingException` and `com.fasterxml
The FRIEND_IP variable in the consumer-vars.env file has been updated to point to the new IP address "192.168.1.4". This change was necessary to redirect the event-sourcing/producer endpoint to the updated server location.
A new variable LOG_LEVEL with a value of DEBUG was added in the consumer-vars.env file. This will provide more detailed logs, enhancing troubleshooting and understanding of the application behaviour.
The @controller annotation was replaced with @RestController in MainController.java file. This change allows the controller to automatically serialize the response objects into JSON, simplifying the controller's implementation by removing the need to manually handle the serialization.
The update from @controller to @RestController in MainController.java allows automatic serialization of response objects into JSON. This simplifies the controller's implementation by obviating manual serialization handling.
nawaphonOHM
force-pushed
the
event-sourcing/main
branch
from
March 10, 2024 14:54
be5c4e8
to
ffcbf91
Compare
The changed Dockerfile paths and tags in Docker build action will now correctly locate the Dockerfiles for messaging instead of event sourcing. The adjustments in the Github workflow yaml file will ensure the accurate building and pushing of both consumer and producer images under the new messaging suite.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.