Commit ac5de671 authored by Arie Valdano's avatar Arie Valdano

FIXING : Setup Config Swagger and Springboot

parent fd3f2af6
......@@ -114,6 +114,11 @@
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
......
......@@ -36,7 +36,10 @@ public class SecurityConfig {
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(
req -> req.requestMatchers(
"/api/authentication/**")
"/api/authentication/**",
"/swagger-ui/**",
"/v3/api-docs/**",
"/swagger-ui.html")
.permitAll()
.anyRequest()
.authenticated()
......
package com.eksad.masterdata.controller;
import com.eksad.masterdata.domain.MstWo;
import com.eksad.masterdata.service.KafkaProducerService;
import com.eksad.masterdata.service.ProcessHelperService;
import com.eksad.masterdata.service.WOService;
import io.vertx.core.json.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
......@@ -19,9 +17,6 @@ public class SampleMasterdataWoController {
@Autowired
WOService woService;
@Autowired
KafkaProducerService kafkaProducerService;
@GetMapping("/test")
public ResponseEntity<String> test(){
System.out.println("test admin");
......@@ -40,15 +35,4 @@ public class SampleMasterdataWoController {
return ResponseEntity.ok(response);
}
@PostMapping("/mqSend")
public ResponseEntity<String> mqSend(@RequestBody String request){
//to simplyfy tracing request lets generate transactionId
JsonObject jsonRequest=new JsonObject(request)
.put("transactionId",processHelperService.createProcessId());
kafkaProducerService.sendMessage(jsonRequest.encode());
JsonObject jsonResponse=new JsonObject()
.put("status","SUCCESS")
.put("message","message send successfully");
return ResponseEntity.ok(jsonResponse.encode());
}
}
package com.eksad.masterdata.event;
import com.eksad.masterdata.common.Constants;
import io.vertx.core.json.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@Service
public class KafkaEvent {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
@KafkaListener(topics = Constants.topicStep1, groupId = "my-group")
public void listenStep1(String message) {
JsonObject jsonMessage=new JsonObject(message);
String transactionId=jsonMessage.getString("transactionId");
System.out.println(
String.format("Starting Step 1 - new taskid %s with paylod [[ %s ]]",
transactionId,
jsonMessage));
//do something here
jsonMessage.put("resultStep1","step 1 a success");
//lets continue to other queue
kafkaTemplate.send(Constants.topicStep2,jsonMessage.encode());
System.out.println(
String.format("done Step 1 for taskid %s %n%n",transactionId));
}
@KafkaListener(topics = Constants.topicStep2, groupId = "my-group")
public void listenStep2(String message) {
JsonObject jsonMessage=new JsonObject(message);
String transactionId=jsonMessage.getString("transactionId");
System.out.println(
String.format("Starting Step 2 - new taskid %s with paylod [[ %s ]]",
transactionId,
jsonMessage));
//do something here
jsonMessage.put("resultStep2","step 2 a success");
System.out.println(
String.format("done Step 2 for taskid %s with final result [[ %s ]] %n%n",
transactionId,
jsonMessage.encode()));
}
}
package com.eksad.masterdata.service;
import com.eksad.masterdata.common.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@Service
public class KafkaProducerService {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
public void sendMessage(String message) {
kafkaTemplate.send(Constants.topicStep1, message);
System.out.println(String.format("done sending for new incoming task [%s bytes] %n%n",message.length()));
}
}
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