Saturday 30 December 2017

Microservices architecture design using Zuul and Eureka - part 3

Microservices architecture design using Zuul and Eureka - part 3


VIDEO:





Products-crawler



Module
Used For
Module Type
Port
Registered Name
Dependencies added
products-crawler
Eureka Client
SpringBoot Module
9001
products-crawler
Web, Discovery Client


application.yml



spring:
 application:
   name: products-crawler


server:
 port: 9001


eureka:
 client:
   registerWithEureka: true
   fetchRegistry: true
   serviceUrl:
     defaultZone: http://127.0.0.1:9002/eureka/
 instance:
   hostname: localhost


Endpoints:


crawlByProductName
GET
http://localhost:9001/crawlers/products/product/{Banana}
crawlByCategoryName
GET
http://localhost:9001/crawlers/products/categories/category/{categoryname}

Get Crawl Data:


private List<ProductCrawl> getCrawlData() {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<List<ProductCrawl>> crawlData = restTemplate.exchange("https://next.json-generator.com/api/json/get/4k2T-g0z4",
HttpMethod.GET, null, new ParameterizedTypeReference<List<ProductCrawl>>() {
           });
List<ProductCrawl> productCrawls = crawlData.getBody();
return productCrawls;
}


ProductCrawl.java
package com.sachin4java.productscrawler.model;


import java.util.Map;


public class ProductCrawl {
private String productName;
private Map<String, String> prices;
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public Map<String, String> getPrices() {
return prices;
}
public void setPrices(Map<String, String> prices) {
this.prices = prices;
}


}

Module products-crawler --> Repository https://github.com/ranesaci/products-crawler.git

No comments:

Post a Comment

Extract error records while inserting into db table using JDBCIO apache beam in java

 I was inserting data into postgres db using apache beam pipeline. it works perfectly with JdbcIO write of apache beam library. But, now, i ...