Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Grails 4 and Micronaut at Devnexus 2019

480 views

Published on

Presentation given by Micronaut and Grails creator Graeme Rocher on Grails 4 and how it integrates with Micronaut.

Published in: Software
  • Very exciting news. Since there is a current trend to separate frontend from backend, I don't think Grails plugins will be very useful anymore. So Grails users can benefit from Micronaut configurations, and Micronaut users can benefit from Grails plugins migrated to configurations. A wise decision!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Grails 4 and Micronaut at Devnexus 2019

  1. 1. GRAILS 4 AND MICRONAUT Getting the best out of Grails 4 and Micronaut
  2. 2. About Me • Graeme Rocher • Creator of Grails and Micronaut • Principal Engineer at Object Computing • Oracle Groundbreaker Award Winner
  3. 3. Agenda • Introduction to Micronaut • Introduction to Grails 4 • Grails vs Micronaut • Using Micronaut Features in Grails • Demos
  4. 4. Micronaut for Grails Developers • Micronaut a Foundational Library for building applications of any type • Focuses on Small Memory Footprint and Speed • Eliminates Reflection, Runtime Proxies and Runtime Analysis
  5. 5. Why Micronaut? • Micronaut is uses no reflection, no runtime proxies, no runtime byte code generation etc. • Eliminating these leads to reduced memory consumption and faster startup • Increasingly important for Microservices, Serverless, IoT, any low-memory footprint environment
  6. 6. Micronaut vs Grails Micronaut Grails Range of Runtimes Servlet Only General Purpose Traditional Servlet Web Apps DI, AOP etc. Spring for DI, AOP etc. Java, Kotlin, Groovy, GraalVM Groovy Only Client and Server Server Only
  7. 7. Grails 4 and Micronaut • Micronaut the Parent ApplicationContext • Made possible by • http://github.com/micronaut- projects/micronaut-spring • Micronaut Libraries become usable in Grails • Anything we build for Micronaut benefits Grails
  8. 8. What Can/Should You Do • Build Configurations (Instead of Plugins) • Use Declarative Clients • HTTP • Kafka • RabbitMQ
  9. 9. Configurations vs Plugins • Consider Building Configurations instead of Plugins • Work with Micronaut, Spring (with micronaut-spring) and Grails • Plugins only work with Grails • ... although some things only possible with Plugins (Views, taglibs etc.)
  10. 10. DEMOMicronaut Configurations with Grails
  11. 11. Micronaut Configurations • Configuration with @ConfigurationProperties • Beans with @Singleton, @Factory etc. • Conditional Behaviour with @Requires • Customization with @Replaces
  12. 12. @ConfigurationProperties Type Safe Configuration @ConfigurationProperties("example") class ExampleConfiguration { String name } ApplicationContext context = ApplicationContext.run("example.name":"Demo") FooConfiguration config = context.getBean(FooConfiguration) assert config.name == 'Demo'
  13. 13. @Requires Conditional Beans Made Easy @Requires(property="example.enabled") @Requires(beans=DataSource) @Requires(missingBeans=Example) @Singleton class DefaultExampleBean implements Example { ... } def context = ApplicationContext.run("example.enabled":"true") Example example = context.getBean(Example)
  14. 14. @Replaces Easily Replace Beans by Type @Replaces(DefaultExample) @Singleton class AlternativeExample implements Example { ... } • Types match much • Beans annotated with @Infrastructure not replaceable
  15. 15. DEMOMicronaut HTTP Client
  16. 16. @Client Declarative Compile Time HTTP Clients @Client("https://api.github.com") @Header(name="User-Agent", value="micronaut-client") interface GithubClient { @Get("/repos/{+slug}") Info getInfo(String slug) } • Blocking or Non-Blocking (RxJava, Reactor or Future) • Reflection / Runtime Proxy Free
  17. 17. @Client • Uses Micronaut's low-level HTTP client (RxHttpClient) under the hood • Built with Micronaut AOP (reflection/ runtime proxy free) • Works on GraalVM nativeimage • Integrates with Tracing, Metrics, Service Discovery etc.
  18. 18. DEMOMicronaut Kafka Client
  19. 19. @KafkaClient Declarative Compile Time Kafka Clients @KafkaClient public interface ProductClient { @Topic("my-products") void sendProduct(@KafkaKey String brand, String name); } • Blocking or Non-Blocking (RxJava, Reactor or Future) https://github.com/micronaut-projects/micronaut-kafka
  20. 20. @RabbitClient Declarative Compile Time Kafka Clients @RabbitClient("animals") interface AnimalClient { void send(@Header String animalType, Animal animal) } • Blocking or Non-Blocking (RxJava, Reactor or Future) https://github.com/micronaut-projects/micronaut-rabbitmq
  21. 21. Micronaut Message Consumers • Micronaut Supports Message-Drive Microservices • Can be run as standalone processes (No HTTP server) • Use @RabbitListener for Rabbit • Use @KafkaListener for Kafka https://docs.micronaut.io/1.1.x/guide/ index.html#messaging
  22. 22. Micronaut's Clients • Compile Time • Reflection and Runtime Proxy Free • Java, Groovy or Kotlin • Built with Micronaut AOP https://docs.micronaut.io/1.1.x/guide/ index.html#aop
  23. 23. Summary • Micronaut Provides an Awesome Foundation • Building Blocks to Create Libraries, Configurations and Clients • Most Micronaut Features Available in Grails • Build Micronaut Libraries not Plugins
  24. 24. Q & A

×