In this Engineering With Java newsletter edition, we have hand-picked some interesting Java and Spring articles worth reading. These articles include topics such as microservice frameworks, stateful rest service, micrometer, JUnit, bitcoinJ, Security, Mockito, etc.
I hope you will like the selections! If you, please consider sharing it, your support means a lot!
🚀 Unlock Your Path to Success with the Ultimate Everything Bundle! 🚀
Introducing the Everything Bundle — your one-stop solution to mastering Java, Spring Boot, SQL, acing interviews, and securing certifications!
1. Top 7 Java Microservices Frameworks
Java remains a robust choice for building microservices, supported by a variety of frameworks that cater to different needs and preferences. Each framework has its unique strengths and potential drawbacks, making them suitable for different types of projects.
Carefully consider your project's specific needs, including performance requirements, development speed, scalability, and ecosystem compatibility, to choose the right framework.
2. Exploring Cost-Effective Solutions for Stateful Rest Services
This article discusses strategies for cost-effectively implementing stateful REST services using cloud-based solutions. Key points include:
IBM Cloud Code Engine: Utilized for running containerized workloads without needing to manage the underlying infrastructure. It supports automatic scaling and pay-per-use pricing models, which can be more cost-effective for variable workloads.
EclipseStore: An open-source storage solution that integrates seamlessly with Java applications. It provides a scalable and performant way to manage stateful data.
IBM Cloud Object Storage (COS): Used for persistent storage. It is highly scalable, durable, and cost-effective for storing large amounts of data.
The combination of these technologies allows for the creation of stateful REST services that are both scalable and cost-efficient, leveraging the strengths of each component to optimize performance and cost.
3. A Guide to Micrometer in Quarkus
This article discusses monitoring applications built with Quarkus. Micrometer is a tool that helps developers track the performance of their applications. The article outlines different ways to use Micrometer including counters, timers, and gauges.
Counters track how many times an operation occurs. Timers track how long an operation takes. Gauges provide a snapshot of a metric at a single point in time.
🚀 Grokking the Java Interview 🚀
Crack your Java interview by preparing important topics and mastering key concepts in a guided and structured way in a short time.Â
4. Top 10 Must-Known Features Of JUnit
This article highlights essential features in JUnit, a widely used Java testing framework, to enhance testing efficiency and effectiveness. Here’s a summary of the key features discussed:
Test Timeouts: The
@Test(timeout)
annotation helps prevent tests from running indefinitely by specifying a maximum duration for each test.Expected Exceptions: JUnit supports testing for expected exceptions using
@Test(expected = Exception.class)
and theassertThrows()
method, allowing verification of exception handling.Parameterized Tests: The
@ParameterizedTest
annotation enables running the same test with different inputs, useful for testing various scenarios without duplicating code.Rules and Extensions: JUnit 4's Rules and JUnit 5's Extensions allow customization of test behavior, resource management, and implementation of additional functionality with minimal code.
Test Suites: The
@RunWith
and@Suite
annotations facilitate organizing tests into suites, enabling the execution of multiple test classes together.Assumptions: Assumptions (
Assume.assumeTrue
) allow tests to be skipped based on certain conditions, ensuring tests only run when relevant.Tagging and Filtering: The
@Tag
annotation in JUnit 5 allows categorization of tests, making it easier to run specific subsets of tests.Nested Tests: The
@Nested
annotation in JUnit 5 allows hierarchical organization of related tests within test classes, enhancing readability and maintainability.Dynamic Tests: The
@TestFactory
annotation supports creating tests dynamically at runtime, useful for data-driven testing and scenarios where test parameters are not known until runtime.Test Templates: The
@TestTemplate
annotation allows defining test templates to execute the same test logic with different data sets or parameters, providing flexibility in test execution.
These features collectively make JUnit a powerful tool for writing comprehensive and reliable tests, helping developers ensure code quality and reduce bugs.
5. Introduction to BitcoinJ
BitcoinJ is an open-source library that allows Java developers to interact with the Bitcoin network without the need for a local Bitcoin node. It can be used for creating Bitcoin wallets, handling transactions, and more.
Key Features:
Wallet Management: BitcoinJ offers comprehensive tools for creating and managing Bitcoin wallets. This includes handling wallet files, encryption, and hierarchical deterministic (HD) wallets.
Transactions: The library supports creating, signing, and broadcasting transactions. It also handles transaction confidence levels and provides tools to listen for transaction events.
Network Operations: BitcoinJ enables connection to the Bitcoin network, managing peer connections, and downloading the blockchain.
6. Exploring Java’s Units of Measurement API
This article introduces the Units of Measurement API (JSR 385) as a solution, noting its absence in the JDK. The author anticipates mixing British and American English in unit names due to the API's convention.
The challenges arise from managing various measurement systems, including SI units and non-SI units like US Customary or Imperial units. The lack of consistency in conversions can result in errors and inefficiencies.
7. Return Auto-Generated ID From Insert With MyBatis and Spring
This article discusses how to return auto-generated IDs when using Spring with MyBatis, a persistence framework for Java. It walks through the process of configuring MyBatis with Spring, setting up the DAO (Data Access Object) layer, and defining mapper XML files.
The tutorial demonstrates how to handle auto-generated IDs for different databases, including MySQL, PostgreSQL, and Oracle. It provides code examples and explains the configuration steps required for each database type, ensuring developers can efficiently work with auto-generated IDs in their Spring-MyBatis projects.
8. Using Amazon S3 with Spring Cloud AWS
This article delves into integrating Spring Cloud AWS with Amazon S3, a popular cloud storage service. It starts by outlining the basics of Amazon S3 and then discusses how to set up Spring Cloud AWS to work with it.
The tutorial covers configuring AWS credentials and the necessary dependencies in a Spring Boot project. It then provides examples of interacting with S3 buckets, including uploading and downloading files using Spring's RestTemplate and ResourceLoader.
The article concludes with tips on handling exceptions and troubleshooting common issues when working with Spring Cloud AWS and S3. Overall, it offers a comprehensive guide for developers looking to utilize Amazon S3 within their Spring applications.
9. Implement your own Rule-Engine in Spring Boot
The linked article provides a guide on implementing a rule engine in a Spring Boot application. It starts by explaining the concept of a rule engine and its benefits. Then, it walks through the process of creating a rule engine using Spring Boot, including defining rules, configuring the rule engine, and implementing rule evaluation.
The tutorial also covers aspects such as rule persistence, dynamic rule loading, and testing strategies. By following the steps outlined in the article, developers can integrate a rule engine into their Spring Boot projects to manage complex business logic effectively.
10. Hibernate ON CONFLICT DO clause
The article discusses the "ON CONFLICT DO" clause in Hibernate, which is a feature introduced in PostgreSQL for handling conflicting data during INSERT operations. It explains how this clause can be used to handle unique constraint violations and perform conditional updates in PostgreSQL.
The article provides code examples demonstrating how to use this feature with Hibernate's JPA and native SQL support. Additionally, it covers potential issues and limitations of using "ON CONFLICT DO" with Hibernate, such as handling composite primary keys and batch inserts.
Overall, it offers valuable insights into leveraging PostgreSQL's conflict resolution capabilities within Hibernate applications.
🚀 Ace Your Next System Design Interview 🚀
Taught by a best-selling author, everything you need to take your system design skills to the next level.