Commit a36e15b3 authored by Mahesh Rohra's avatar Mahesh Rohra

After review process modified code

parent 0e22b472
......@@ -27,6 +27,8 @@ repositories {
}
dependencies {
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.7.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.7.0'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
......
......@@ -7,7 +7,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@EnableFeignClients("com.safeway.epe.*")
@EnableFeignClients("com.safeway.epe.client")
public class StoreProducerApplication {
public static void main(String[] args) {
......
package com.safeway.epe.config;
package com.safeway.epe.client;
import com.safeway.epe.domain.ConsumerPayload;
......
package com.safeway.epe.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.safeway.epe.controller"))
.paths(PathSelectors.any())
.build();
}
}
package com.safeway.epe.service;
import com.safeway.epe.config.ProducerServiceProxy;
import com.safeway.epe.client.ProducerServiceProxy;
import com.safeway.epe.domain.ConsumerPayload;
import com.safeway.epe.domain.Offsets;
import com.safeway.epe.domain.TransactionPayload;
......@@ -9,6 +9,7 @@ import com.safeway.epe.repository.TransactionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -50,10 +51,17 @@ public class ProducerService
else
{
transactionRepository.updateProcessedFlagByTransactionId(false,transactionRecorder.getUuid());
transactionService.errorResponse(transactionRecorder, "failed to insert data to topic", false);
errorResponse(transactionRecorder, "failed to insert data to topic", false);
logger.info("failed to insert data to topic");
return new ArrayList<>();
}
}
private ResponseEntity<String> errorResponse(TransactionRecorder transactionRecorder, String exceptionMessage, boolean isReprocesed) {
if(!isReprocesed){
logger.error("Error response : "+ exceptionMessage);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error");
}
}
package com.safeway.epe.service;
import com.safeway.epe.domain.Offsets;
import com.safeway.epe.domain.TransactionRecorder;
import org.springframework.http.ResponseEntity;
import java.util.List;
public interface TransactionService
{
ResponseEntity<List<Offsets>> produceMessage(String uuid);
ResponseEntity<List<Offsets>> sendData(TransactionRecorder transactionRecorder, boolean isReprocesed);
ResponseEntity<String> errorResponse(TransactionRecorder transactionRecorder, String exceptionMessage, boolean isReprocesed);
}
......@@ -53,10 +53,4 @@ public class TransactionServiceImpl implements TransactionService
return ResponseEntity.ok(offsetsList);
}
public ResponseEntity<String> errorResponse(TransactionRecorder transactionRecorder, String exceptionMessage, boolean isReprocesed) {
if(!isReprocesed){
logger.error("Error response : "+ exceptionMessage);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error");
}
}
......@@ -2,7 +2,7 @@ package com.safeway.epe.util;
import com.safeway.epe.domain.TransactionRecorder;
import com.safeway.epe.repository.TransactionRepository;
import com.safeway.epe.service.TransactionService;
import com.safeway.epe.service.TransactionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -16,7 +16,7 @@ public class StoreScheduler
TransactionRepository transactionRepository;
@Autowired
private TransactionService transactionService;
private TransactionServiceImpl transactionService;
@Scheduled(fixedRateString = "${offertransaction.reprocess.timedelay}",initialDelay = 77777)
public void processTransactionData(){
......
package com.safeway.epe.service;
import com.safeway.epe.config.ProducerServiceProxy;
import com.safeway.epe.client.ProducerServiceProxy;
import com.safeway.epe.domain.ConsumerPayload;
import com.safeway.epe.domain.Offsets;
import com.safeway.epe.domain.TransactionPayload;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment