<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:g-custom="http://base.google.com/cns/1.0" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
  <channel>
    <title>e380ff2d</title>
    <link>https://www.newrayllc.com</link>
    <description />
    <atom:link href="https://www.newrayllc.com/feed/rss2" type="application/rss+xml" rel="self" />
    <item>
      <title>Deploying a Spring Cloud Function on AWS Lambda Platform using Serverless Framework</title>
      <link>https://www.newrayllc.com/deploying-a-spring-cloud-function-on-aws-lambda-platform-using-serverless-framework</link>
      <description />
      <content:encoded>&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           If Java Is Your Choice Of Programming Language – Spring Cloud Function + Serverless Framework Makes A Great Technology Stack. It Boosts Developer Productivity By Decoupling From Vendor Specific FaaS API, And Deployment Activities.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Quick introduction to Spring Cloud Function
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Spring Cloud Function provides an uniform programming model to develop functions which can be run on any Function-as-a-Service platforms like AWS Lambda. The same code can run as a web endpoint, a stream processor, or a task. Also, enables Spring Boot features. More information is availabe at 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://cloud.spring.io/spring-cloud-function/" target="_blank"&gt;&#xD;
      
           Spring Cloud Function
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      
           .
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Quick introduction to Serverless Framework
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           I found the definition of Serverless Framework @ 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://serverless.com/" target="_blank"&gt;&#xD;
      
           Serverless
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      
            Inc. is precisely explained.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;blockquote&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless is your toolkit for deploying and operating serverless architectures. Focus on your application, not your infrastructure.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/blockquote&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Example project (
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://github.com/mbsambangi/aws-java-spring-cloud-function-demo" target="_blank"&gt;&#xD;
      
           Source Code @ GitHub
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      
           )
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Use-case
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This is a scenario in which when we provide a Member ID, the service should reply with the type of coverage that member has. In this fictional scenario it always returns a coverage type as MEDICAL for a given Member ID.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Function
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           @Bean
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           public Function&amp;lt;HealthFirstMemberRequest, HealthFirstMemberResponse&amp;gt; members() {
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
              return member -&amp;gt; {
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
                 HealthFirstMemberResponse response = new HealthFirstMemberResponse();
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
                 response.setMemberId(member.getMemberId());
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
                 response.setCoverage(HealthFirstMemberResponse.Coverage.MEDICAL);
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
                  return response;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
                  };
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           }
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           AWS Lambda Handler
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A Handler class which just implements SpringBootRequestHandler is needed. This is what we are going to configure in serverless.yml file.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Maven POM file
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           The following dependencies in POM.xml file does all the magic of generating AWS specific Lambda code.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;spring-cloud-function-adapter-aws&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;com.amazonaws&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;aws-lambda-java-core&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;version&amp;gt;${aws-lambda-core.version}&amp;lt;/version&amp;gt;&amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Generating deployable Artifact
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Run following command to generate deployable / uploadable .jar file.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $mvn clean package
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This gnerates a JAR file ‘
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           member-function-0.0.1-SNAPSHOT-aws.jar
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           ‘ under target folder. Serverless Framework uploads this JAR file to AWS Lambda.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Installing Serverless Framework
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Run following command to install Serverless Framework from NPM
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $npm install serverless -g
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After installing you can run serverless or short form sis command to use Serverless Framework.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           To check the command type
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $serverless version
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           or
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $sls version
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Configuring serverless.yml file
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We need to define serverless.yml file with all the settings needed.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           service: sls-aws-java-spring-cloud-function-demo
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           provider:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             name: aws
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             runtime: java8
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             timeout: 10
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           package:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             artifact: target/aws-java-spring-cloud-function-demo-0.0.1-SNAPSHOT-aws.jar
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           functions:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             members:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
               handler: com.healthfirst.memberfunction.AwsLambdaHandler
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
               environment:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
                 FUNCTION_NAME: members
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Deploying on AWS Lambda Platform
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Run following command to deploy the project on AWS Lambda
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $sls deploy -v --aws-profile &amp;lt;your aws profile&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           You would see something similar to this
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Packaging service...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Creating Stack...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Checking Stack create progress...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::CloudFormation::Stack - sls-aws-java-spring-cloud-function-demo-dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucket
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_COMPLETE - AWS::CloudFormation::Stack - sls-aws-java-spring-cloud-function-demo-dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Stack create finished...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Uploading CloudFormation file to S3...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Uploading artifacts...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Uploading service .zip file to S3 (12.91 MB)...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Validating template...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Updating Stack...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Checking Stack update progress...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - sls-aws-java-spring-cloud-function-demo-dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - MembersLogGroup
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::Logs::LogGroup - MembersLogGroup
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_COMPLETE - AWS::Logs::LogGroup - MembersLogGroup
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Function - MembersLambdaFunction
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Function - MembersLambdaFunction
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_COMPLETE - AWS::Lambda::Function - MembersLambdaFunction
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Version - MembersLambdaVersionN8TC7eR31v5vRUjauJUxtjhrj6n1C123yUgLKetxebM
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_IN_PROGRESS - AWS::Lambda::Version - MembersLambdaVersionN8TC7eR31v5vRUjauJUxtjhrj6n1C123yUgLKetxebM
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - CREATE_COMPLETE - AWS::Lambda::Version - MembersLambdaVersionN8TC7eR31v5vRUjauJUxtjhrj6n1C123yUgLKetxebM
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - sls-aws-java-spring-cloud-function-demo-dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           CloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - sls-aws-java-spring-cloud-function-demo-dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Stack update finished...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Service Information
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           service: sls-aws-java-spring-cloud-function-demo
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           stage: dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           region: us-east-1
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           stack: sls-aws-java-spring-cloud-function-demo-dev
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           api keys:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             None
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           endpoints:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             None
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           functions:members: sls-aws-java-spring-cloud-function-demo-dev-members
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Stack Outputs
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           MembersLambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:899022498951:function:sls-aws-java-spring-cloud-function-demo-dev-members:1
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           ServerlessDeploymentBucketName: sls-aws-java-spring-clou-serverlessdeploymentbuck-1qadcge7s5r27
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Run following command to invoke the function
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $ sls invoke -f members -l --aws-profile &amp;lt;your AWS profile name&amp;gt; --data '{"memberId":"1234567890"}'
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This will invoke the function by passing the Member ID. You would see console output with response MEDICAL as below.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           {
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
               "memberId": "1234567890",
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
               "coverage": "MEDICAL"
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           }
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           --------------------------------------------------------------------
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           START RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Version: $LATEST
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           13:58:36.347 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Initializing: class com.healthfirst.memberfunction.MemberFunctionApplication
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             .   ____          _            __ _ _
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
            /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
            \\/  ___)   _)             (_     ) ) ) )
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
             '   ____  .__|_   _|_   _\__,   / / / /
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
            =========|_|==============|___/=/_/_/_/
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
             :: Spring Boot ::                       
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           2018-06-30 13:58:39.013  INFO 1 --- [           main] lambdainternal.LambdaRTEntry             : Starting LambdaRTEntry on ip-10-22-39-231.ec2.internal with PID 1 (/var/runtime/lib/LambdaJavaRTEntry-1.0.jar started by sbx_user1060 in /)
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           2018-06-30 13:58:39.016  INFO 1 --- [           main] lambdainternal.LambdaRTEntry             : No active profile set, falling back to default profiles: default
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           2018-06-30 13:58:39.297  INFO 1 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@23fe1d71: startup date [Sat Jun 30 13:58:39 UTC 2018]; root of context hierarchy
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           2018-06-30 13:58:44.069  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           2018-06-30 13:58:44.152  INFO 1 --- [           main] lambdainternal.LambdaRTEntry             : Started LambdaRTEntry in 7.536 seconds (JVM running for 8.879)
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           END RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            REPORT RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f  Duration: 8002.57 ms    Billed Duration: 8100 ms        Memory Size: 1024 MB    Max Memory Used: 142 MB
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Run the following command to uninstall the project from AWS
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $sls remove --aws-profile &amp;lt;your aws profile&amp;gt;
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This one command will uninstall the stack on AWS cloud so that you may not be charged for any more usage.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Getting all objects in S3 bucket...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Removing objects in S3 bucket...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Removing Stack...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Checking Stack removal progress...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           ........
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless: Stack removal finished...
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Summary
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           If Java is your choice of programming language – Spring Cloud Function + Serverless Framework makes a great technology stack. It boosts developer productivity by decoupling from Vendor specific FaaS API, and deployment activities.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;</content:encoded>
      <enclosure url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-593158.jpeg" length="87784" type="image/jpeg" />
      <pubDate>Tue, 31 Jan 2023 03:06:21 GMT</pubDate>
      <guid>https://www.newrayllc.com/deploying-a-spring-cloud-function-on-aws-lambda-platform-using-serverless-framework</guid>
      <g-custom:tags type="string">lambda,serverless</g-custom:tags>
      <media:content medium="image" url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-593158.jpeg">
        <media:description>thumbnail</media:description>
      </media:content>
      <media:content medium="image" url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-593158.jpeg">
        <media:description>main image</media:description>
      </media:content>
    </item>
    <item>
      <title>TDD of Microservice-Nanoservice Combination with a Contract (In other words, SpringBoot-SpringFunction Combo with a Spring RestDocs-Contract)</title>
      <link>https://www.newrayllc.com/tdd-of-microservice-nanoservice-combination-with-a-contract-in-other-words-springboot-springfunction-combo-with-a-spring-restdocs-contract</link>
      <description />
      <content:encoded>&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This Article Attempts To Demonstrate How Powerful Is Test Driven Development &amp;amp; Consumer-Driven-Contract When There Is A Dependency On An Internal/External Service. If There Is A Mix Of Microservices And Nanoservices This Approach Really Boosts Developer Productivity To Produce Quality Testable Code.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           What is this all about?
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Most of the monolithic applications developed are modularized into layers (tiers) based on their purpose like Web (Client-side), Business logic (Server-side), database access (Database-side). Slicing the application vertically based on bounded contexts into independent micro-monoliths is like a microservices architectural style.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Spring Boot &amp;amp; Spring Cloud Frameworks made the Development of Microservice style applications easy.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           PaaS (Platform-as-a-Service) offerings like Cloud Foundry made the Operations part of microservices easy with simple configurations and deployments.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless programming (sometimes referred to as Nanoservices) is gaining popularity day by day. All major cloud vendors have Serverless computing platforms. Serverless computing sometimes also called FaaS (Function-as-a-Service).
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           If a project is a collection of Microserivces, chances are a few of those microservices fit right as Nanoservices or a remote Nanoservice (serverless) dependency may exist. And then that project can be a combination of Microservices-Nanoservices.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           TDD (Test Driven Development) is essential to tackle the complexity and communication between services. Consumer-Driven-Contracts are handy and reduce the dependency on other services during development.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           From a developers point of view what matters is the programming language, development Framework, and ease of testing and deployment.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           In this blog post I am trying to address the Dev part of DevOps with a simple Microserivce-to-Nanoservice style project by taking advantage of Spring Cloud Framework.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           What are all “good to know”?
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Familiarity with following Spring Frameworks is good to know.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Spring Boot &amp;amp; MockMvc
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Spring Cloud Function
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Spring Cloud Contract
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Spring RestDocs
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           I have provided links to various resources at the end of this blog post to get an understanding of these concepts.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Sample Application
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Use case:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           When you call a doctor’s office to schedule an appointment, they first verify your health insurance to make sure you have right coverage.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Design:
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           First we develop an appointment REST service at Doctor’s Office application. Then a members function at fictional Health Insurance company (HealthFirst) application to verify insurance coverage.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Typical workflow is
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            We call Doctor-Office’s appointment request REST service by supplying First name, Last name, and Health Insurance MemberID.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Appointment request REST service in-turn calls Health Insurance company’s Member-Function to get given member’s coverage level.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            ﻿
           &#xD;
      &lt;/span&gt;&#xD;
      
           Doctor-Office (Hospital) [Consumer of the Contract]
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Doctor-Office is an independent Spring boot service. We expose a REST service to request an appointment. This application consumes Health Insurance’s Member-Function Serverless application.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/consumer_uml.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Member-Function (Health Insurance Company) [Producer of the Contract]
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Member-Function is a Spring Cloud Function. It provides coverage level for a given member Id.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This is the producing service which produces the service contract to check its member’s coverage type.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://github.com/mbsambangi/member-function" target="_blank"&gt;&#xD;
      
           Full Source Code is here
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            ﻿
           &#xD;
      &lt;/span&gt;&#xD;
      
           Consumer-Driven-Contract initiated from Producer side
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           In a Consumer-Driven-Contract the contract starts from consumer side. Here Doctor-Office is the consuming application and Health Insurance companies Member-Function app is the producing application.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           But, it makes more sense if Health Insurance company publishes its contract out to all associated hospitals.New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/cdc.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           In this sample application, lets generate a service contract at Health Insurance application. Then, publish that contract out so that any doctor’s office (Hospital) would know how to check health insurance coverage.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Nanoservice - Member-Function (Contract Producer)
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After considering all the design aspects Health Insurance check application is better suited to be developed as a Nanoservice, aka a serverless application.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           For following reasons this can be a serverless app
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Its a simple check service.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Used by various associated hospitals via different communication channels (Web, Messaging, events)
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Doesn’t need to be up and running all the time.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            No need to gauge the load and traffic.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Setup
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets implement Health Insurance company’s Member-Function app using Spring Cloud Function. We need following dependencies in our pom.xml to start with.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Serverless apps are invoked by events via various channels. Lets choose Web channel to keep it simple. We need spring-cloud-starter-function-web. This starter BOM provides Function implementation also exposes the function as a REST web serivce.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;spring-cloud-starter-function-web&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Then, we need RestDocs dependency for generating doc snippets.New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.restdocs&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;spring-restdocs-mockmvc&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           And, we need ASCII Doc dependency to generate html out of doc snippets.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.restdocs&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;artifactId&amp;gt;spring-restdocs-asciidoctor&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           To integrate Rest Docs with Cloud Contract we need following WireMock dependency.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;artifactId&amp;gt;spring-cloud-contract-wiremock&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Spring-cloud-starter-contract-verifier BOM is needed if we are writing a DSL contract manually. We don’t need this here as we are not going to write DSL contract. Rest Docs auto generate the DSL contract for us.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, we need following plugin to assemble generated contract and stubs to publish out to consuming applications. To demonstrate, we install the stubs jar to local Maven repository.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;plugin&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;maven-assembly-plugin&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;configuration&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;attach&amp;gt;true&amp;lt;/attach&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;descriptors&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             	&amp;lt;descriptor&amp;gt;${project.basedir}/src/assembly/stub.xml&amp;lt;/descriptor&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;/descriptors&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;/configuration&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;executions&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             	&amp;lt;execution&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             		&amp;lt;id&amp;gt;stub&amp;lt;/id&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             		&amp;lt;phase&amp;gt;prepare-package&amp;lt;/phase&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;goals&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               		&amp;lt;goal&amp;gt;single&amp;lt;/goal&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               	&amp;lt;/goals&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               	&amp;lt;inherited&amp;gt;false&amp;lt;/inherited&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               &amp;lt;/execution&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             &amp;lt;/executions&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/plugin&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           and the stub.xml which defines the assembly rules. Please refer the codebase for the stub.xml file.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We don’t need spring-cloud-contract-maven-plugin as we are not going to generate test-case out of DSL contract. Because, we are going to auto generate DSL from a test-case.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           TDD
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets start with a failing test-case. We use MockMvc to call the function which I am going to describe in a bit.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           So, we invoke the function by passing in a HealthFirstMember object. Member ID is mandatory field and other fields are optional.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After invoking the Mock service we check if the coverage is MEDICAL to pass the test-case.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @Test
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public void provideCoverageForGivenMemberId() throws Exception {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           HealthFirstMember member = new HealthFirstMember();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           member.setMemberId("123456789");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           member.setCoverage(HealthFirstMember.Coverage.NONE);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           MvcResult result = mockMvc.perform(post("/members")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .contentType(MediaType.APPLICATION_JSON_UTF8)
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .content(json.write(member).getJson())
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ).andReturn();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           mockMvc.perform(asyncDispatch(result))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .andExpect(status().isOk())
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .andExpect(jsonPath("coverage").value("MEDICAL"))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We will revisit the test-case when we are ready to generate contracts and docs.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            ﻿
           &#xD;
      &lt;/span&gt;&#xD;
      
           Member Function
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           In order to pass the test-case we need to real implementation of a Function. Following code snippet shows how this is implemented using Spring Cloud Function.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public static void main(String[] args) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           SpringApplication.run(MemberFunctionApplication.class, args);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @Bean
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public Function&amp;lt;HealthFirstMember, HealthFirstMember&amp;gt; members() {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           return member -&amp;gt; {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           member.setCoverage(HealthFirstMember.Coverage.MEDICAL);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           return member;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           };
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, if you run the test-case it should pass.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/function-test-pass.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            ﻿
           &#xD;
      &lt;/span&gt;&#xD;
      
           Contract Generation
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now we have a passing test-case and implementation. We are ready to generate a contract and stubs out of it.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets re-visit the test-case to achieve this.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets add following annotation so Rest Docs can generate snippets.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @AutoConfigureRestDocs(outputDir = "target/snippets")
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Then, we can call WireMockRestDocs.verify() method to register and check request/response. Then call the .stub() to store reqeust/response stubs.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           mockMvc.perform(asyncDispatch(result))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andExpect(status().isOk())
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andExpect(jsonPath("coverage").value("MEDICAL"))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andDo(WireMockRestDocs.verify().jsonPath("$.memberId")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .contentType(MediaType.APPLICATION_JSON_UTF8).stub("healthfirst-member-check"))
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Finally, we call SpringCloudContractRestDocs.dslContract() by passing it to MockMvcRestDocumentation.document() to generate the DSL contract.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After, all the above steps the completed test-case looks like this.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public void provideCoverageForGivenMemberId() throws Exception {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   HealthFirstMember member = new HealthFirstMember();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   member.setMemberId("123456789");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   member.setCoverage(HealthFirstMember.Coverage.NONE);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   MvcResult result = mockMvc.perform(post("/members")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .contentType(MediaType.APPLICATION_JSON_UTF8)
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .content(json.write(member).getJson())
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   ).andReturn();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   mockMvc.perform(asyncDispatch(result))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andExpect(status().isOk())
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andExpect(jsonPath("coverage").value("MEDICAL"))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andDo(WireMockRestDocs.verify().jsonPath("$.memberId")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .contentType(MediaType.APPLICATION_JSON_UTF8).stub("healthfirst-member-check"))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   .andDo(MockMvcRestDocumentation.document("healthfirst-member-check",
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                           SpringCloudContractRestDocs.dslContract()));
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               }
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, run
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           $mvn clean install
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           and check the target folder. Generated snippets, docs, json stub, and dsl groovy contract should be available under snippets folder.New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/target-snippets.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           The stubs.jar is installed to local Maven repository. Which serves as the contract and shared with consuming application.New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/function-stub.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Microserivce - Doctor-Office - (Contract Consumer)
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets implement this consuming application a simple Spring boot service with a simple REST service. This application calls our Nanoservice Member-Function above to check a member’s coverage.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           As we are doing TDD and offline development we need code against to the shared contract.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Setup
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We need following dependencies in our pom.xml to start with.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We are going to write a REST controller we need spring-boot-starter-web.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           To call the Health Insurance company’s Member-Function we can use either RestTemplate or Feign. Lets use Feign. So, we need Feign dependency for defining a Feign Client Interface
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;spring-cloud-starter-openfeign&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, we need contract stub runner to run the stub shared by Health Insurance company.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;spring-cloud-starter-contract-stub-runner&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Finally, we need the Member-Function stub dependency listed as dependency. Following dependency gets the -stubs.jar which we installed to local maven repository before.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;com.healthfirst&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;member-function&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;classifier&amp;gt;stubs&amp;lt;/classifier&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;version&amp;gt;0.0.1-SNAPSHOT&amp;lt;/version&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;exclusions&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;exclusion&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;groupId&amp;gt;*&amp;lt;/groupId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;artifactId&amp;gt;*&amp;lt;/artifactId&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/exclusion&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/exclusions&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           &amp;lt;/dependency&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           TDD
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets write a failing test-case for the REST controller. We use MockMvc to call the controller which I am going to describe in a bit.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           So, we invoke the controller by passing in a Appointment object. We need Firstname, Lastname, and memberId.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After invoking the Mock service we check if the appointment is CONFIRMED to pass the test-case.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @Test
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public void scheduleAppointmentWhenPatientHasCoverage() throws Exception {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Appointment appointment = new Appointment();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           appointment.setFirstName("Madhu");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           appointment.setLastName("Sambangi");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           appointment.setMemberId("123456789");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           appointment.setDateOfBirth("01/01/2018");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           mockMvc.perform(post("/api/v1/appointments")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .contentType(MediaType.APPLICATION_JSON_UTF8)
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .content(objectMapper.writeValueAsString(appointment))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .accept(MediaType.APPLICATION_JSON_UTF8))
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .andDo(print()).andExpect(status().isOk())
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           .andExpect(jsonPath("status").value("CONFIRMED"));
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We will revisit the test-case when we are ready to generate contracts and docs.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Appointments REST Service
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We need the controller implemented to pass the test-case. Also, inject the HealthFirstService Feign client so that it can call Member-Function.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @RestController
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @RequestMapping("api/v1")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public class PatientController {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           private HealthFirstService healthFirstService;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public PatientController(HealthFirstService healthFirstService) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           this.healthFirstService = healthFirstService;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @PostMapping("/appointments")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public AppointmentResponse appointments(@RequestBody Appointment appointment) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           AppointmentResponse response = new AppointmentResponse();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           HealthFirstMember member = new HealthFirstMember();
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           member.setMemberId(appointment.getMemberId());
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           member = healthFirstService.verifyCoverage(member);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           if (member.getCoverage() == HealthFirstMember.Coverage.MEDICAL) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           response.setStatus(AppointmentResponse.AppointmentStatus.CONFIRMED);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           return response;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Feign Client to call Member Function
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           And the Feigin client to call the Health Insurance’s Memebr-Function service.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @FeignClient(name = "HealthFirstService",
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               url = "http://localhost:8080", fallback = HealthFirstService.HealthFirstServiceFallback.class)
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public interface HealthFirstService {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               @RequestMapping(method = RequestMethod.POST, path = "/members")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               @Headers("Accept:application/json;charset=UTF-8")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               HealthFirstMember verifyCoverage(@RequestBody HealthFirstMember member);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               @Component
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               class HealthFirstServiceFallback implements HealthFirstService {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   @Override
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   public HealthFirstMember verifyCoverage(@RequestBody HealthFirstMember member) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                       member.setCoverage(HealthFirstMember.Coverage.NONE);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                       return member;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                   }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, if you run the test-case it still fails complaining ‘Connection Refused’ error. Because Feign client tries to call the Member-Function at http://localhost:8080. We haven’t configured the stub runner in the test case to mock the Member-Function using the contract yet.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            ﻿
           &#xD;
      &lt;/span&gt;&#xD;
      
           Stubs from Member-Function Contract
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets re-visit the test-case to configure the stub so that Feign client will work.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets add following annotation in Test class so the stub will run at localhost port 8080.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @AutoConfigureStubRunner(ids = "com.healthfirst:member-function:+:stubs:8080", stubsMode = StubRunnerProperties.StubsMode.LOCAL)
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
      &lt;/span&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Appointments Test
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now the test case passes covering end-to-end testing.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Calling the appointment REST controller First
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           MockHttpServletRequest:
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                 HTTP Method = POST
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                 Request URI = /api/v1/appointments
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                  Parameters = {}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                     Headers = {Content-Type=[application/json;charset=UTF-8], Accept=[application/json;charset=UTF-8]}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                        Body = {"firstName":"Madhu","lastName":"Sambangi","memberId":"123456789","dateOfBirth":"01/01/2018"}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               Session Attrs = {}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Handler:
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                        Type = com.hospital.doctoroffice.PatientController
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                      Method = public com.hospital.doctoroffice.AppointmentResponse com.hospital.doctoroffice.PatientController.appointments(com.hospital.doctoroffice.Appointment)
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Which calls the Feign client for member’s coverage.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           127.0.0.1 - POST /members
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           User-Agent: [Java/1.8.0_131]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Connection: [keep-alive]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Host: [localhost:8080]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Accept: [*/*]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Content-Length: [40]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Content-Type: [application/json;charset=UTF-8]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           {"memberId":"123456789","coverage":null}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Feign client calls the stubbed Health Insurance’s Member-Function and gets the member’s coverage as per the contract.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Matched response definition:
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             "status" : 200,
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             "body" : "{\"memberId\":\"123456789\",\"coverage\":\"MEDICAL\"}",
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             "headers" : {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               "Content-Type" : "application/json;charset=UTF-8"
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
             }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            PatientController checks the coverage and returns CONFIRMED if the coverage is MEDICAL.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           MockHttpServletResponse:
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                      Status = 200
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               Error message = null
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                     Headers = {Content-Type=[application/json;charset=UTF-8]}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                Content type = application/json;charset=UTF-8
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                        Body = {"status":"CONFIRMED"}
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
               Forwarded URL = null
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
              Redirected URL = null
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
                     Cookies = []
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Finally, the test case passes if the appointment status is CONFIRMED.
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/microservice-test.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Summary
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This article attempts to demonstrate how powerful is Test Driven Development &amp;amp; Consumer-Driven-Contract when there is a dependency on an internal/external service. If there is a mix of microservices and nanoservices this approach really boosts developer productivity to produce quality testable code.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Please go over the Resources &amp;amp; References section below to learn more of the various pieces of the Spring Framework I used in the sample application, also to understand more about the keywords like microservices, nanoservices, and serverless.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;span&gt;&#xD;
        
            ﻿
           &#xD;
      &lt;/span&gt;&#xD;
      
           Resources &amp;amp; References
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://www.slideshare.net/ewolff/nanoservices-and-microservices-with-java" target="_blank"&gt;&#xD;
      
           Microserivces &amp;amp; Nanoservices with Java
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="http://cloud-samples.spring.io/spring-cloud-contract-samples/tutorials/rest_docs.html" target="_blank"&gt;&#xD;
      
           Spring Cloud Contract with RestDocs
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://github.com/spring-cloud/spring-cloud-function" target="_blank"&gt;&#xD;
      
           Spring Cloud Function
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://martinfowler.com/articles/serverless.html" target="_blank"&gt;&#xD;
      
           Serverless Architecture
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;</content:encoded>
      <enclosure url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-4657256.jpeg" length="218871" type="image/jpeg" />
      <pubDate>Tue, 31 Jan 2023 02:56:41 GMT</pubDate>
      <guid>https://www.newrayllc.com/tdd-of-microservice-nanoservice-combination-with-a-contract-in-other-words-springboot-springfunction-combo-with-a-spring-restdocs-contract</guid>
      <g-custom:tags type="string">TDD</g-custom:tags>
      <media:content medium="image" url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-4657256.jpeg">
        <media:description>thumbnail</media:description>
      </media:content>
      <media:content medium="image" url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-4657256.jpeg">
        <media:description>main image</media:description>
      </media:content>
    </item>
    <item>
      <title>Application Logging &amp; Log Draining in Cloud Foundry</title>
      <link>https://www.newrayllc.com/application-logging-log-draining-in-cloud-foundry</link>
      <description />
      <content:encoded>&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Introduction
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           The main goal of this blog post is to provide necessary information to get started on using Cloud Foundry Logging Component. A little introduction to concepts like Cloud-Native Apps, 12 Factor Apps is needed to understand System and Application logging on Cloud. Here is the breakdown of this blog post.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            The purpose of aggregating logs from all running instances of an application on cloud.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            How the aggregation of logs is handled on Open-Source PaaS - Cloud Foundry.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            How easy it is to route the log streams to a specialized log management system - Papertrail.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Prerequisite
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This article assumes you are familiar with
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Cloud foundry
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            A brief understanding of Cloud Native Applications.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            A high-level understanding of 12 Factor Apps concepts.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           I have provided links to various resources at the end of this article to get an understanding of these concepts before you go on and read this blog post.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Why do we need to aggregate logs?
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Cloud Native Apps
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Applications designed and developed to take advantage of cloud features are supposed to be called cloud native apps. Following constraints makes cloud native applications difficult to troubleshoot.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ol&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Distributed applications like microservices hard to maintain, and debug.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Applications on cloud run on Virtual machines and(or) Containers which are ephemeral.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Container Instances are immutable.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ol&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Because of these constraints storing, analyzing application and system log information is difficult.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           12 factor Apps
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           12 factor apps is like a benchmarking to make sure your application is built for cloud (like microservices) and following certain recommendations.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Among the 12 factors following four factors are pertinent to topic of this post.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ol&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Processes - 12 factor apps are supposed to be state-less so that scaling is easy.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Concurrency - For high availability multiple instances of an App are run and load is distributed across.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Disposability - To scale-out and scale-in, Apps should be quick to boot-up and easy to be disposable.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Logs - 12 factor apps recommends treating logs from all app instances as event streams, never store them inside containers or virtual machines.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ol&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Logs should be streamed out and stored somewhere else and should be aggregated not to loose them.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           What component of Cloud Foundry handles logging?
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Cloud Foundry Loggregator Component
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A brief introduction to Cloud foundry
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Cloud Foundry is an open-source Platform-As-A-Service (Paas) to run applications on any cloud. Instead of focusing on Cloud infrastructure CF abstracts all the operational activities and provides a platform to speedup application development and deployment. Various components of CF address certain factors of 12 factor operations. Loggregator component of CF takes care of aggregation of logs from all running instances of an application.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Following diagram explains various sub components within PCF Loggragator Component.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/pcf_loggregator.png" alt="" title=""/&gt;&#xD;
  &lt;span&gt;&#xD;
  &lt;/span&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Loggregator
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Cloud Foundry Loggregator component aggregates logs from all app instances for you. All the developer needed to do is direct the logs to standard OUT and standard ERROR.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Loggreator comprises of two sub-components
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Doppler: Receives app syslogs from Metron agents. These can be further redirected to log drain systems like Papertrail or Loggly.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Traffic Controller: Collects both syslogs and metrics data. Syslogs can be pulled out from CFCLI command $cf logs. Or CF administrators can setup Nozzles to direct metrics data to third party APM (Application Performance Monitoring) tools like NewRelic.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           How can we take advantage of CF Loggregator?
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A quick lab using Pivotal Cloud Foundry and Papertrail Managed Log Management System.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt; Push sample application onto PCF
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           To demonstrate log drain lets quickly build a sample Spring boot application. Please go to 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="http://start.spring.io/" target="_blank"&gt;&#xD;
      
           http://start.spring.io
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      
           . Configure a sample Spring boot application with Web Starter dependency.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Here is the Sample Spring Boot Application for this lab. I just added a REST Controller which logs a log message appending the name it receives from the API call.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @SpringBootApplication
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public class PcflogApplication {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public static void main(String[] args) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           SpringApplication.run(PcflogApplication.class, args);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @RestController
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @RequestMapping("api/v1")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public class PcfLogDemo {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Logger logger = LoggerFactory.getLogger(PcfLogDemo.class);
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           @GetMapping("hello/{name}")
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           public ResponseEntity&amp;lt;String &amp;gt; sayHello(@PathVariable String name) {
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           logger.info(name + ": Your log statement");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           return ResponseEntity.ok().body(name + ": Your Log statement.");
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           }
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Please go ahead and build the application using Maven. After successful build the app should be available under target/{your app}.jar. Maven build log of the sample application.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ pcflog ---
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           [INFO] Building jar: /Users/msambangi/Downloads/pcflog/target/pcflog-0.0.1-SNAPSHOT.jar
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           [INFO]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           [INFO] --- spring-boot-maven-plugin:2.0.0.RELEASE:repackage (default) @ pcflog ---
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           [INFO] ------------------------------------------------------------------------
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           [INFO] BUILD SUCCESS]
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
            
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt;Signup for free account on Pivotal Web services
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now our sample app is ready to be deployed on Pivotal Cloud Foundry. Please go ahead and create a free account @ Pivotal Web services.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/pws-signup+%281%29.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After an account was setup on PWS. Please download and setup CFCLI on your machine. CFCLI provides access to PWS from command line tool. Here is how you need to login to PWS from your command line tool of choice.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $ cf login
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           API endpoint:
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;code&gt;&#xD;
      &lt;a href="https://api.run.pivotal.io/" target="_blank"&gt;&#xD;
        
            https://api.run.pivotal.io
           &#xD;
      &lt;/a&gt;&#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Email&amp;gt; &amp;lt;email associated with PWS account&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Password&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Authenticating...
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           OK
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Targeted org cloudmonkey
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Targeted space development
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           API endpoint:
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;code&gt;&#xD;
      &lt;a href="https://api.run.pivotal.io/" target="_blank"&gt;&#xD;
        
            https://api.run.pivotal.io
           &#xD;
      &lt;/a&gt;&#xD;
    &lt;/code&gt;&#xD;
    &lt;code&gt;&#xD;
      
           (API version: 2.103.0)
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           User:           &amp;lt;email associated with PWS&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Org:            cloudmonkey
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Space:          development
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After successful login you would see similar information above with your org name, and space. My target SPACE is development under ORG cloudmonkey. You may setup your choice of ORG and SPACE when you signup.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Pushing app to PCF is very simple with one command 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           cf push
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           . Following screen print shows that my app push is successful.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $ cf push pcf-log-demo -p ./target/pcflog-0.0.1-SNAPSHOT.jar
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           state     since                    cpu    memory        disk       details
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           #0  running   2018-03-08 04:17:00 PM   0.0%   43.8K of 1G   8K of 1G
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Of course, you can always verify the app status on your PWS Console.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           PWS Console
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Its time to verify the app on PCF. PCF by default provides a route point to your application as {your-app-name}.cfapps.io. Please see the screen print below where my api call to my app by passing in my name.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           I can see the output on screen “Madhu: Your log statement.”. Ok. The app is running and working as expected.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $ http
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;code&gt;&#xD;
      &lt;a href="http://pcf-log-demo.cfapps.io/api/v1/hello/Madhu" target="_blank"&gt;&#xD;
        
            http://pcf-log-demo.cfapps.io/api/v1/hello/Madhu
           &#xD;
      &lt;/a&gt;&#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           HTTP/1.1 200 OK
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Connection: keep-alive
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Content-Length: 26
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Content-Type: text/plain;charset=UTF-8
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Date: Thu, 08 Mar 2018 21:22:06 GMT
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           X-Vcap-Request-Id: a08352e2-80ac-4239-5c8e-74179366a2ae
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Madhu: Your Log statement.
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now lets try to pull logs from the app using CFCLI. The command to do that is simple. 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $cf logs {your-app-name}
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           . Here I can see the log statement from my app.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $ cf logs pcf-log-demo
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Retrieving logs for app pcf-log-demo in org cloudmonkey / space development as...
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           2018-03-09T12:10:15.26-0500 [RTR/5] OUT pcf-log-demo.cfapps.io - [2018-03-09T17:10:15.206+0000] "GET /api/v1/hello/Madhu HTTP/1.1" 200 0 26 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6" "10.10.2.227:2584" "10.10.148.72:61074" x_forwarded_for:"100.36.74.10, 10.10.2.227" x_forwarded_proto:"http" vcap_request_id:"4ef29682-cc19-429c-55c4-d7fa9431c618" response_time:0.053996806 app_id:"2295fb9c-176c-47ab-96e9-e736cfb91c51" app_index:"0" x_b3_traceid:"6d02249b20d1757c" x_b3_spanid:"6d02249b20d1757c" x_b3_parentspanid:"-"
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           2018-03-09T12:10:15.26-0500 [RTR/5] OUT
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           2018-03-09T12:10:15.37-0500 [RTR/3] OUT pcf-log-demo.cfapps.io - [2018-03-09T17:10:15.307+0000] "GET /favicon.ico HTTP/1.1" 200 0 946 "
          &#xD;
    &lt;/code&gt;&#xD;
    &lt;code&gt;&#xD;
      &lt;a href="http://pcf-log-demo.cfapps.io/api/v1/hello/Madhu" target="_blank"&gt;&#xD;
        
            http://pcf-log-demo.cfapps.io/api/v1/hello/Madhu
           &#xD;
      &lt;/a&gt;&#xD;
    &lt;/code&gt;&#xD;
    &lt;code&gt;&#xD;
      
           " "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6" "10.10.2.227:3791" "10.10.148.72:61074" x_forwarded_for:"100.36.74.10, 10.10.2.227" x_forwarded_proto:"http" vcap_request_id:"cdef7da2-57bd-404c-55b2-0d381bbf922c" response_time:0.063308529 app_id:"2295fb9c-176c-47ab-96e9-e736cfb91c51" app_index:"0" x_b3_traceid:"3ecb42e4d552b946" x_b3_spanid:"3ecb42e4d552b946" x_b3_parentspanid:"-"
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           2018-03-09T12:10:15.37-0500 [RTR/3] OUT
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           2018-03-09T12:10:15.24-0500 [APP/PROC/WEB/0] OUT 2018-03-09 17:10:15.247  INFO 13 --- [nio-8080-exec-1] c.e.pcflog.PcflogApplication$PcfLogDemo  : Madhu: Your log statement
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt; Create a free account on Papertrail
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Directing logs to a Cloud-hosted Log Management helps us further evaluate the logs. We get more tools to anaylyze, search, also setup notifications based on certain conditions. Here I am going to leverage Papertrail cloud-hosted Log Management system to direct logs from my app instance to my papertrail account.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Please go ahead and signup for a free account on Papertrail.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After you login to your Papertrail account, please go ahead and add a system to receive log messages.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt; Setup Log Event listener system on papertrail
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Copy the log URL provided by Papertrail. We need this URL to configure a Service Broker at PWS.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt; Create a Service Broker
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           At PWS as a first step you need to create a service broker for your Papertrail account. Create a User-Provided-Service using 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $cf cups {service-name} -l {url from papertrail}
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
            command.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $ cf cups papertrail-dump-demo -l syslog://logs.papertrailapp.com:&amp;lt;port provided by papertrail&amp;gt;
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Creating user provided service papertrail-dump-demo in org cloudmonkey / space development as ...
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           OK
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt; Connect Service Broker to sample application
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           After the service was created, we need to bind it to the app. CFCLI command 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           $cf bs {app-name} {service-name}
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
            does the binding. After successful binding you would see a TIP to restage the app. Sometimes restaging is needed if the service which we are binding may need to configure agents inside the app container. In this example its not necessary.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $ cf bs pcf-log-demo papertrail-dump-demo
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           Binding service papertrail-dump-demo to app pcf-log-demo in org cloudmonkey / space development as ...
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           OK
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           TIP: Use 'cf restage pcf-log-demo' to ensure your env variable changes take effect
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;code&gt;&#xD;
      
           ~/Downloads/pcflog $
          &#xD;
    &lt;/code&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           &amp;gt; View Logs on Papertrail Web Console
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now you need to invoke the sample application above one more time to generate a log message. After waiting a few seconds the app syslogs would start showing up on Papertrail web console.New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/papertrail_log_listen+%281%29.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/papertrail_first_log+%281%29.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/papertrail-live-log+%281%29.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           That’s it. Its a very simple demonstration of distributed logging and log management. But, this is very powerful and elegant and makes a developer / operational person’s life easy to debug, troubleshoot a cloud hosted application.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Summary
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           As distributed systems are hard to debug and maintain, apps run inside immutable containers and virtual machines with ephemeral disks, we need a mechanism to aggregate logs from all running instances. CF Loggregator Component comes to the rescue. It collects logs from all the running instances and provides them as event streams. We can process the stream of logs in various ways like tail the logs using $cf logs {app-name} or divert them to sophisticated log management systems like 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://papertrailapp.com/" target="_blank"&gt;&#xD;
      
           Papertrail
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      
            or Splunk. This addresses the 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           logs factor
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
            of 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://12factor.net/" target="_blank"&gt;&#xD;
      
           12 Factor Apps
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      
           .
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Resources &amp;amp; References
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://pivotal.io/cloud-native" target="_blank"&gt;&#xD;
      
           Cloud Native Apps
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://12factor.net/" target="_blank"&gt;&#xD;
      
           12 Factor Apps
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://www.cloudfoundry.org/why-cloud-foundry/" target="_blank"&gt;&#xD;
      
           Cloud Foundry
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://docs.pivotal.io/pivotalcf/2-0/loggregator/architecture.html" target="_blank"&gt;&#xD;
      
           Loggregator documentation @Pivotal
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://app.pluralsight.com/library/courses/cloud-foundry-developer-1dot7-pivotal/table-of-contents" target="_blank"&gt;&#xD;
      
           Pivotal Cloud Foundry Developer Course @Pluralsight
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/h5&gt;&#xD;
  &lt;h5&gt;&#xD;
    &lt;span&gt;&#xD;
      
           - 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://papertrailapp.com/" target="_blank"&gt;&#xD;
      
           Papertrail
          &#xD;
    &lt;/a&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h5&gt;&#xD;
&lt;/div&gt;</content:encoded>
      <enclosure url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-296333.jpeg" length="632829" type="image/jpeg" />
      <pubDate>Tue, 31 Jan 2023 02:49:06 GMT</pubDate>
      <guid>https://www.newrayllc.com/application-logging-log-draining-in-cloud-foundry</guid>
      <g-custom:tags type="string">logging</g-custom:tags>
      <media:content medium="image" url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-296333.jpeg">
        <media:description>thumbnail</media:description>
      </media:content>
      <media:content medium="image" url="https://irp.cdn-website.com/md/pexels/dms3rep/multi/pexels-photo-296333.jpeg">
        <media:description>main image</media:description>
      </media:content>
    </item>
    <item>
      <title>Flutter- Bottom Navigation Bar- Navigation using Dart Streams &amp; BLoC Pattern</title>
      <link>https://www.newrayllc.com/flutter-bottom-navigation-bar-navigation-using-dart-streams-bloc-pattern</link>
      <description />
      <content:encoded>&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Dart’s StreamController and Flutter’s StreamBuilder are powerful tools to achieve a better design and intra-app communication.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Prerequisites
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Basic understanding of Flutter SDK and Scaffold Material Widget.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Dart Programming Language. (Basic idea of Streams).
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            BLoC Pattern — (Writing logic separate from UI in a Dart class and sharing it among Widgets).
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Main focus is Scaffold Widget’s body and bottomNavigationBar sections.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;blockquote&gt;&#xD;
    &lt;span&gt;&#xD;
      
           “The Scaffold widget takes a number of different widgets as named arguments, each of which are placed in the Scaffold layout in the appropriate place.”
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/blockquote&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           The most significant among those named arguments are
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            appBar: (The top section)
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            body: (Main body section)
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            bottomNavigationBar: (Bottom section)
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Navigating between screens using Scaffold’s bottomNavigationBar can be achieved in many different ways. Most common way is
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Hold the current BottomNavigationBarItem index value inside the State of a StatefulWidget every time a BottomNavigationBarItem was tapped,
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            and
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Call that State’s setState() to repaint the whole widget tree to reflect those changes.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A slightly better approach can be using a combination of
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            BLoC — to separate business logic from UI
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Dart’s StreamController — to communicate the UI intents.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Flutter’s StreamBuilder — to trigger UI updates.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Advantages
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Using BLoC we can achieve clear separation of business logic from UI.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            No need to store current BottomNavigationBarItem index inside the State.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            No need to call setState() every time which re-creates the entire widget tree.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Use StreamBuilder to re-create only a sub-tree or widget(s) instead of entire widget tree.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           So, how can it be achieved?
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Two key things
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Communication between the Scaffold’s bottomNavigationBar and body sections is done using Dart’s StreamController.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            Use Flutter’s StreamBuilder to re-paint just the body section and the BottomNavigationBar.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           First thing we need a BLoC
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Let’s create a BLoC. This BLoC holds
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            an enum to represent various BottomNavigationBarItems.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            a dart StreamController object.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            a default Navigation Bar Item enum for initial state.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            a function which can be attached to onTap() gesture of BottomNavigationBar on UI side.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            a method to close the stream.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Lets go over each piece of BLoC in detail…
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            an enum to represent various BottomNavigationBarItems.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h2&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h2&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_WUVV8K5nkXxAPPz5h9_B2Q.png" alt="" title=""/&gt;&#xD;
  &lt;span&gt;&#xD;
  &lt;/span&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           by listing out the Bottom NavBar Items as enum fields it’s easy to read the code and we can take advantage of enum indexes.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            A Dart StreamController.
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      &lt;br/&gt;&#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_kMTdQoepMcxwppQzCpsPHw.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Note: By default, Dart StreamController’s Stream is not a broadcast type stream. We can create one by calling broadcast() as shown in the screen print.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           We need a broadcast type stream because, both body and bottomNavigationBar sections of the Scaffold listen-on the same stream to switch view based on current NavBarItem tapped.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            A default Navigation Bar Item enum for initial state
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_RTHezw4t9fxpzKlNuDKfUw.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, we need to set a default NavBarItem to show the default screen and NavBarItem selected. Let’s just set HOME as default.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;ul&gt;&#xD;
    &lt;li&gt;&#xD;
      &lt;span&gt;&#xD;
        
            A function which can be attached to onTap() gesture on UI
           &#xD;
      &lt;/span&gt;&#xD;
    &lt;/li&gt;&#xD;
  &lt;/ul&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;br/&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_gheH3vcKHQQF_7hR4xOiCQ.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This function holds the index tracking logic inside the BLoC separate from UI. This gets called out by onTap() when any BottomNavigationBarItem is tapped and receives the index of the tapped BottomNavigationBarItem.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Finally a handy method to close the stream (It’s a good practice to close the streams when not needed)
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_ejvhX_KDllYQ0YkXatqR0A.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Because navBarController is a private field inside the BLoC we need a handy method to close the stream from outside of the BLoC.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h3&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Now, UI part of the app
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h3&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A StatefulWidget A StatefulWidget/State combo is not necessarily needed because we are not going to depend on setState() method anyway.
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_wW7xLPKmi9L_pZYVDr3-cg.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           But, closing the Dart Stream when not needed is a best practice. This can be achieved by calling BLoC’s close() method inside State’s dispose() lifecycle method. So, we need a StatefulWidget here.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A State
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_eI2PmOUKZLN-G_Fqw3y3AA.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           State’s lifecycle methods initState() creates the BLoC and dispose() closes the stream when not needed.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           A StreamBuilder to switch the body section by listening to the NavBar item stream of the BLoC.
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_T8VMzynTw_igVh0cfXtPfA.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           StreamBuilder in body section listens to BLoC’s stream and based on the NavBarItem enum in the current snapshot, it switches to corresponding view. Initial snapshot has the default NavBarItem (NavBarItem.HOME) and body will show homeArea().
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Another StreamBuilder to update the BottomNavigationBar to highlight the BarItem selected and feed the stream with onTap()
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;span&gt;&#xD;
      
           New Paragraph
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_QAeh3sHPURHVBRtFFSzclA.png" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           This StreamBuilder listens to same stream but builds the BottomNavigationBar and highlights the BottomNavigationBarItem based on the NavBarItem enum in current snapshot of the stream. So, initial snapshot has default NavBarItem (HOME) and Home BarItem gets highlighted.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           onTap: Calls the BLoC’s pickItem() function and supplies selected BarItem’s index value on tap. BLoC’s pickItem() feeds-in the stream with a NavBarItem enum based on the index it receives. This triggers the whole action.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           In Action…
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div&gt;&#xD;
  &lt;img src="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/1_S4j5v4PwfukdxNutxB83BQ.gif" alt=""/&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;div data-rss-type="text"&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           Full source code is 
          &#xD;
    &lt;/span&gt;&#xD;
    &lt;a href="https://github.com/mbsambangi/flutter_navbar_bloc_streams_demo" target="_blank"&gt;&#xD;
      
           here…
          &#xD;
    &lt;/a&gt;&#xD;
  &lt;/p&gt;&#xD;
  &lt;h1&gt;&#xD;
    &lt;span&gt;&#xD;
      
           End Note
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/h1&gt;&#xD;
  &lt;p&gt;&#xD;
    &lt;span&gt;&#xD;
      
           I am sure there are many different ways of doing it. But, the above approach is certainly one clean way to separate the logic from UI. Dart’s StreamController and Flutter’s StreamBuilder are powerful tools to achieve a better design and intra-app communication. I hope this article is useful.
          &#xD;
    &lt;/span&gt;&#xD;
  &lt;/p&gt;&#xD;
&lt;/div&gt;</content:encoded>
      <pubDate>Tue, 31 Jan 2023 02:43:01 GMT</pubDate>
      <guid>https://www.newrayllc.com/flutter-bottom-navigation-bar-navigation-using-dart-streams-bloc-pattern</guid>
      <g-custom:tags type="string">mobile</g-custom:tags>
      <media:content medium="image" url="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/Google-flutter-logo.svg">
        <media:description>thumbnail</media:description>
      </media:content>
      <media:content medium="image" url="https://irp.cdn-website.com/30c3dcaf/dms3rep/multi/Google-flutter-logo.svg">
        <media:description>main image</media:description>
      </media:content>
    </item>
  </channel>
</rss>
