Java Digest # VI: Spring Boot III.II, AWS Lambdas on Java XXI, Amazon Q, RabbitMQ III.XIII
?? Aloha, friends!?
Tell me, do you love spring as much as we do? Yes? Well, then, this issue is for you! Because there will be a lot of news about Spring.
In addition, in this issue, you will find news about the latest events in the world of Java for November.
And don't get tripped up by those Roman numerals. Just keep a keen eye on our digest, and you'll figure it all out in an instant ??????
You can read the previous digest here.
? Java
Although the main focus of this digest issue is the long-awaited release of new versions of Spring and Spring Boot, there was also a lot happening in the world of Java.
After completion of the review, JEP CDLX: Vector API (Seventh Incubator) was promoted from Proposed to Target to Targeted for JDK XXII. Under Project Panama's auspices, this JEP incorporates enhancements in response to feedback from the previous six rounds of incubation.
JEP CDLIX: String Templates(II Preview) was also promoted to “Proposed to Targeted” for JDK XXII.
The discussion on the OpenJDK mailing list addresses a question about the syntax of String Templates in Java, particularly why both a template prefix (like <processor>.) and the backslash (`\`) are required for embedded expressions. Brian Goetz explains that several factors, including the need for uniformity and ease of migration for existing Java code, influenced this design choice. Java programs often contain string literals with dollar signs, which could conflict with template expressions if not handled carefully. The backslash escape mechanism is already established in Java, making it a logical choice for extending to template expressions. This approach ensures seamless use of existing strings with new features, reduces linguistic complexity, and lowers the risk of errors. The use of backslashes, rather than inventing a new escape mechanism, aligns with existing practices and minimizes the learning curve for Java developers.
Gavin Bierman has published a draft specification for JEP CDLXIII: Implicit Classes and Instance Main Methods (II Preview) to the broader Java community. Now, this feature is awaiting its review.
In the LVIII issue of Inside Java, Nicolai Parlog discusses Java on GPU.
In the XXI issue of JEP Cafe, José Paumard explains how to optimize your equals methods using pattern matching.?
In his Sip of Java, Billy Korando demonstrates the advantages of pattern matching for switch.
Also, and this is not a drill, emoji support in Java XXI has been significantly improved!
?? Spring Updates
This day has arrived! We have finally seen the full release of Spring Framework VI.I and Spring Boot III.II. On this occasion, we want to share the most exciting changes included in the release versions. And there are indeed many of them! So, let's prepare some tea with biscuits and dive into the latest innovations.
Recently, Java XXI was released, bringing numerous innovations. However, the most exciting is the introduction of virtual threads. The Spring team has been considering using virtual threads for quite some time. The main goal was to implement virtual threads without completely rewriting the API to simplify the transition for all interested developers. And what can we say? They succeeded.
To use virtual threads in your projects, you need to do two things:
When virtual threads are enabled, Tomcat and Jetty will use them to process requests. It means that the code in your application that handles web requests, such as a method in a controller, will be executed in a virtual thread. Additionally, virtual threads have also impacted other Spring components. Here are some of them:
It's important to note that virtual threads are not a one-size-fits-all solution for all projects. Therefore, the editors recommend conducting empirical research before use. We look forward to hearing your impressions and thoughts on using virtual threads in your Spring Boot projects.
Another significant innovation is the initial support for JVM Checkpoint Restore (Project CRaC).
Let's take a closer look at it. What exactly is Project CRaC? As you may know, Java applications require some time to initialize before processing requests. This problem is known as a cold start, and with the emergence of serverless technologies (such as AWS Lambda), addressing it has become a priority.
Various technologies have emerged in recent years to address the cold start problem in Java applications. These include GraalVM native images, AppCDS, and Project CRaC. Each of these solutions addresses the problem differently, but currently, our focus is on Project CRaC.?
The acronym CRaC stands for Coordinated Restore at Checkpoint. It is an OpenJDK project developed by Azul Systems to accelerate JVM startup time by capturing/freezing its working state, where all the heavy lifting (class loading, JIT compilation, code optimization, etc.) is performed, and serializing this state to disk (Checkpoint) for later restoration (Restore). As a result, the program is in the same state as at the time of creation of the control point.
To utilize the innovations of Project CRaC, the following are required:
In the image below, you can see the time to the first operation, both with and without CRaC. The results are from this repository.
If you're interested in this functionality, here is a repository with a demonstration project.
It's important to note that the files created by CRaC contain a representation of the active JVM in memory, which may include secrets and other confidential data. It's recommended to use this feature while considering that any values "seen" by the JVM, such as configurations from the environment, will be saved in these files. Therefore, it's crucial to thoroughly assess the security implications of how and where these files are generated and stored.
In terms of innovations, the new RestClient and JdbcClient also deserve attention. If you have experience with Spring WebFlux, you will find many similarities between these new clients, WebClient and DatabaseClient.
RestClient can be a decent replacement for RestTemplate, as it offers a convenient DSL (Domain-Specific Language). For more details about this new client, refer to its documentation.
In turn, JdbcClient is a modern alternative to JdbcTemplate, featuring a user-friendly interface similar to the DatabaseClient in R2DBC. This makes it suitable for developers looking for an updated approach to JDBC operations with a more intuitive and efficient interface.
The feature to reload SSL bundles on the fly has been added, and Tomcat and Netty currently support it. Enabling automatic reloading is straightforward. You must add configuration? spring.ssl.bundle.pem.mybundle.reload-on-update and set its value to true. This enhancement dramatically simplifies updating SSL certificates without restarting the server, thereby improving operational efficiency and security compliance.
Under the hood, a file watcher analyzes the files and reloads them if they have changed. Using the configuration
spring.ssl.bundle.watch.file.quiet-period
you can set a quiet period for the file watcher. This feature allows for efficient and timely updates of SSL certificates without unnecessary reloads, ensuring both security and minimal impact on system performance. Click here for more detailed information.
领英推荐
Support for Apache Pulsar has been added. The new starter introduces automatic configurations for key components like PulsarClient, PulsarTemplate, and @PulsarListener, which are used both as message senders and receivers. It also adds support for various authentication methods and TLS. You can read more here.?
Numerous changes related to the Micrometer have also been added. You can find the details in the release notes.
These are just a few of the updates that have been included. You can familiarize yourself with other changes here and there.
Additionally, if you prefer video content, the Starbuxman himself, Josh Long has created an excellent overview of all the significant changes. Spring Tips: Spring Boot 3.2
Indeed, November was a busy month with several maintenance releases. These include:
Spring Session III.II reached General Availability (GA). It introduced SessionIdGenerator for custom session ID generation and secure deserialization of Redis sessions.
Spring Security VI.II also reached GA. Notably, cors() is automatically enabled in this new version if a CorsConfigurationSource component is present.
GA release for Spring Data MMXXIII.I. was announced, introducing support for virtual threads and CRaC. Maintenance releases for Spring Data MMXXIII.N.VI, MMXXII.N.XII, and MMXXI.II.XVIII were also issued.?
Spring Modulith has released two versions: I.I GA and I.N.III. Some of the most exciting changes in I.I include:
Spring Vault III.I: Adds support for Spring Framework VI.I, new Antora-based documentation, JWT authentication, and other improvements.
Spring Tools IV.XX.I: Brings enhancements related to Spring Boot, Eclipse, VS Code, and Theia.
Spring Shell: Four versions were released, the details of which can be found in their respective documentation.
Spring Authorization Server I.II: GA version was released.
Spring for GraphQL I.II.IV: Includes bug fixes, minor improvements, and updated documentation.
Spring for Apache Kafka and Spring for RabbitMQ: Released version III.I.
Spring Cloud MMXXIII.N.N-RCI (aka Leyton): Built on Spring Boot III.II.N-RCI. Major changes can be found in the Spring Cloud Stream project.
Spring Batch: Three versions were released: V.I GA, V.N.IV, and IV.III.X. Version V.I includes dependency updates, virtual threads support, memory management improvements in JpaItemWriter, new Antora-based documentation, and more.
Spring Integration VI.II: The GA version features numerous improvements, including Antora-based documentation, support for virtual threads, and CRaC support.
????? Java in Clouds
?? Other news
?? Netflix & Chill
??Can ChatGPT handle the role of an interviewer? I'll let ChatGPT interview me for a Java role
And some more videos from the latest Devoxx Belgium.
?? Building and Deploying Java Client Desktop Applications With JDK 21 and Beyond By Kevin Rushforth
?? Off-top
How often do our dear readers think about the Roman Empire? If you think the editorial staff is a bit quirky (yes, you are right) and wonder why all the numerals in this issue are Roman, here is a video with a timecode:
And we are very sorry that we came across this diamond that late.
We are going on a short (or not so short) break! Expect the new issue in February MMXXIV.