Skip to content
Snippets Groups Projects
Commit 19ca87d1 authored by Michal Badin's avatar Michal Badin
Browse files

fix(Sending notification): Problem with sending request do not failed whole func

parent d222d51f
No related branches found
No related tags found
2 merge requests!54Merge develop into main,!37feat(Sending notification): Implemented func to send request to notification-module
Pipeline #
......@@ -14,7 +14,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.*;
import java.io.IOException;
import java.util.*;
......@@ -22,11 +22,11 @@ import java.util.*;
@Service
public class CarComponentService extends DomainService<CarComponent> {
private static final Logger log = LoggerFactory.getLogger(CarComponentController.class);
private static final Logger log = LoggerFactory.getLogger(CarComponentService.class);
private final CarComponentRepository componentRepository;
private final RestTemplate restTemplate;
@Value("${http://localhost:8083/notification/notify}")
@Value("${http://localhost:8083/notification}")
private String notificationServiceUrl;
@Autowired
......@@ -40,13 +40,13 @@ public class CarComponentService extends DomainService<CarComponent> {
CarComponent savedComponent = repository.save(component);
try {
sendPostRequest(savedComponent);
} catch (IOException e) {
} catch (RestClientException | IllegalArgumentException e) {
log.debug(String.format("The notification module is not reachable on the URL: %s", notificationServiceUrl));
}
return component;
return savedComponent;
}
private void sendPostRequest(CarComponent component) throws IOException {
private void sendPostRequest(CarComponent component) {
Map<String, Object> notification = new HashMap<>();
notification.put("subject", "New CarComponent added");
notification.put("message", "A new CarComponent with ID " + component.getId() + " has been added.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment