Skip to content

Java and .Net - Better Together. How Spring Cloud Services and Steeltoe can help polyglot solutions work seamlessly together. First shown at MicroSoft Build 2019.

License

Notifications You must be signed in to change notification settings

benwilcock/springcloud-and-steeltoe-demo

 
 

Repository files navigation

Java & .Net - Better Together

A MicroSoft Build 2019 presentation by David Dieruf and Ben Wilcock.

  • The Video of the MS Build talk is here.
  • The slide deck accompanying the talk are here.

Introduction

This code shows how polyglot microservices built using .Net and Java can easily coexist thanks to Spring, Spring Cloud Services, Steeltoe, and Pivotal Application Service (PAS).

In this code we offer technical guidance on how to...

  • externalize configuration in .Net and Java microservices using Spring Cloud Config Server
  • register and discover services dynamically at runtime in .Net and Java using Spring Cloud Service Registry

Prerequisites

This code is intended for use with Pivotal Application Service (PAS) with both the Spring Cloud Services broker and the Azure Services broker installed.

Pivotal Application Service: PAS is a truly polyglot IaaS abstraction layer for both Windows and Linux based applications. it offers a uniquely unified developer experience so that programmers working in many different languages can get their apps into production fast.

Pivotal Application Service (PAS) - fits this usecase exactly

You can try PAS for free for 90 days on Azure.

Understanding the code layout

This repository is organized into two distinct pieces. The .Net application is called "Loan Applications" and is contained within the /loan-application-service folder. The Java application is called "Loan Checker" and is stored in the /loan-approval-service folder.

In the talk and the accompanying slides we discuss how a merger between a fictitious bank and its supplier has brought these two applications together under one roof and we illustrate their 'before and after' architectural landscapes.

Loan Applications (.Net)

You can explore the .Net code in the /loan-application-service folder here. The Loan Applications service is the API that the outside world will use to request a loan from our fictitious bank.

Loan Checker (Java)

You can explore the Java code in the /loan-approval-service folder here. The Loan Checker application acts as a quality gate, checking that loans are not being given to people on te 'naughty list'.

Configuration

Spring Cloud Config Server expects to find its client's configuration files in a Git repository. In this case, the configuration used by both the Java and the .Net applications can be found in the /config folder of this repository (here). This configuration is organised into "profiles", specifically a test profile and a prod profile in order to illustrate just one of the many ways in which Spring Cloud Config can manage your configuration.

Running these applications on PAS

The assumption being made is that you already have access to a PAS instance with all the necessary pre-requisites installed (see above for details).

We're also assuming that you're comfortable using the cf command, and have used it before to comission services and deploy applications. If you have not, it really is super simple - try this guide or talk to your Pivotal account team for help.

Creating the AzureDB and Spring Cloud Registry services is fairly straight-forward (just remember to use the service names in the manifest.yml files for each app for a smooth experience).

Spring Cloud Config Server demands a more specific configuration step, as detailed below.

Telling Spring Cloud Config Server where the config is stored

To create a Spring Cloud Config Server instance correctly, you can use the cf command line client as follows...

cf create-service p-config-server standard config -c config-server.json

The config-server.json file (for example this one) is used to tell the config server which Git repository location you want to use as your config's 'backing store'.

The documentation for Spring Cloud Services (registry and config server) can be found here.

Note: The applications in this demo spell out their service requirements (and the service-names expected) in their Cloud Foundry manifest.yml files (like this one). Use these predefined service names when you commission your services for a more enjoyable deployment experience.

The Finished Article

Once you've set everything up, your polyglot PAS architecture should look something like this...

"After" Architecture Diagram showing both applications, and their services, all running on Pivotal Application Service (PAS)

How to get in touch

We hope you enjoyed the talk and get something useful from this code sample. If you would like to contact us or give us feedback, you can find David Dieruf and Ben Wilcock on Twitter.

About

Java and .Net - Better Together. How Spring Cloud Services and Steeltoe can help polyglot solutions work seamlessly together. First shown at MicroSoft Build 2019.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 57.2%
  • Java 24.7%
  • Shell 13.3%
  • PowerShell 4.8%