Skip to content

Instantly share code, notes, and snippets.

@skryvets
Last active September 26, 2024 23:24
Show Gist options
  • Save skryvets/21b7ff37aa8ffb4522fc7c62c3a4dbeb to your computer and use it in GitHub Desktop.
Save skryvets/21b7ff37aa8ffb4522fc7c62c3a4dbeb to your computer and use it in GitHub Desktop.

Java Conference (JConf) Workshop - Josh Long

Github repository - https://github.com/joshlong-attic/2024-bootiful-spring-workshop

Key Topics from Workshop

Tools and Development Environment

  • IDE choices: IntelliJ, VSCode, Eclipse.
  • Java: GraalVM (team working on it as part of Oracle).
  • Key Resources:
    • start.spring.io: An API, website, and IDE wizard for bootstrapping Spring applications.
    • Devtools: For instant changes during development.
    • Docker Compose: Automates container setup.
    • Testcontainers: Helps with automated testing/dev setup.
  • Amazon Corretto: Mentioned as a widely used Java distribution.

Development Best Practices

  • Spring JavaFormat Plugin:
    • Ensures consistent formatting across teams.
    • GitHub Repository.
    • Note: Still not formatted automatically.
  • Environment Variables:
    • SDKMAN:
      • sdk env init.
      • SDKMAN RC.
      • IntelliJ plugin.
    • direnv: For managing environment variables.
  • Password Management: 1Password/Bitwarden have an API tool for secrets management.
  • Desk check: Ensuring consistent experience for all developers.

Core Concepts and Programming in Java 21+

  • Data-Oriented Programming: Examples in Java 21+.
  • Dependency Injection & Beans:
    • Stereotypes (from UML, describes component function).
    • Bean lifecycle.
    • BeanPostProcessor (BPP).
    • Transaction demarcation.
    • AOP (Aspect-Oriented Programming):
      • Proxy: method point, adds callback to methods.
    • Spring Boot uses BeanPostProcessor to wrap beans.

Advanced Spring Features

  • GraalVM and AOT (Ahead of Time) Compilation:
    • Installing and using GraalVM.
    • Building native images with GraalVM for optimized performance.
    • Managing AOT lifecycles in Spring.
    • Tree-shaking: Optimization by removing unused code (like shaking a tree to remove dead branches). However, it can inadvertently discard necessary code.
    • Challenges with serialization/deserialization: GraalVM only preserves types that are passed as parameters or return types, meaning some features (like serialization) may be discarded.
    • Manual hints: Need to add hints manually to preserve the necessary code, either through JSON configuration or by referring to Oracle documentation.
  • Spring Batch Processing:
    • Loading data from CSV files to SQL databases.

Data Management

  • JdbcClient for database interactions.
  • SQL initialization.
  • Flyway for database migrations.
  • Spring Data JDBC for simpler persistence management.

Web Development and APIs

  • REST Services:
    • RestClient vs RestTemplate (RestClient is newer and preferred; RestTemplate is older and considered legacy).
    • Declarative clients.
  • Creating REST controllers (including functional style).
  • GraphQL: Alternative to REST for querying APIs.

Messaging and Integration

  • Event-Driven Architecture:
    • Messaging technologies like RabbitMQ and Apache Kafka.
  • Spring Integration: Leveraging file-based events to trigger application events.
  • Event Sourcing:
    • Storing and replaying events to rebuild system state.
    • Spring helps with this, and I believe Spring Batch is involved. However, other components like Spring Cloud Stream or Spring Data may also play a role.
    • Ensures consistent event handling and fault tolerance.

Scalability and Multithreading

  • Non-blocking IO: Improves scalability by handling requests asynchronously.
  • Virtual Threads (Project Loom) vs Carrier Threads:
    • Virtual Threads provide lightweight, efficient threading.
  • Demos from José Paumard and Cora Iberkleid showed examples of virtual thread scalability.
  • "Hey" load testing tool for simulating traffic.

Architecting for Modularity

  • Spring Modulith: Building modular monolithic applications with Spring.
  • Externalized Configuration: Managing configurations separately from the application code.
  • Testing:
    • ArchUnit for architecture tests.
    • Port 0: Random Port in Spring Boot for testing purposes.

Artificial Intelligence and Spring

  • Spring AI:
    • Basics of integrating AI models with Spring.
    • Using ChatClient for AI-driven conversations.
  • Retrieval-Augmented Generation (RAG): A technique used in AI for augmenting queries with relevant data.
  • LLAMA: Mentioned as a local AI model option.

Microservices

  • Centralized Configuration: Managing configurations across microservices.
  • API Gateways: Deciding between reactive and non-reactive API gateways.
  • Event Bus: Enables refreshable configuration, service registration, and discovery.

Security

While not covered in detail during the workshop, Josh recommended watching the following video:

  • "Passkeys: Goodbye Passwords, Hello Security! (SpringOne)"

Key concepts mentioned in passing:

  • Authentication and Authorization.
  • OAuth:
    • Spring Authorization Server.
    • OAuth clients and resource servers.
  • Protecting messaging code.

Additional Notes & Personal Takeaways

  • Language Servers: Many language servers, one editor. Can be used with VSCode, VIM, others...
  • "Tuples" in Java: Need to learn more...
  • Identity of Record: "The identity of a record is the identity of the component (constructor)" – a principle mentioned.
  • Resident Size: Mentioned, but further details were not provided.

Q&A Approach

Josh's philosophy during the Q&A session:

  • "I may not know, but I probably know who does know..."

TODO: Add RSS as a tool to measure memory usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment