I have a Contact Entity in my gateway(gw-app) app and I would like to create a entry every time a new user is registered in the UAA app. I have been trying to use the inter service communication described in Jhipster documentation for microservices.
- Fist problem I have here is I don't have this interface
@AuthorizedFeignClient
in the UAA app. - Second, I never got a success creation from uaa to gw-app using
@FeignClient
.
Beside having the communication/configuration issues with the feign client I have some concerns about how this will work when there is no session stablished(new user registering) and then I have another use case where I have an existing session from the user-management screen (when an admin is creating a new user)
UAA config
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.uaa.auth",
"nativeLanguage": "es"
},
"jhipsterVersion": "4.13.3",
"baseName": "UAA",
"packageName": "com.agriket.auth",
"packageFolder": "com/uaa/auth",
"serverPort": "9999",
"authenticationType": "uaa",
"cacheProvider": "hazelcast",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSocialSignIn": false,
"enableSwaggerCodegen": false,
"jwtSecretKey": "8e4167f67e9f8d85cc35b70181a828c691374e58",
"enableTranslation": true,
"applicationType": "uaa",
"testFrameworks": [],
"jhiPrefix": "jhi",
"nativeLanguage": "es",
"languages": [
"es",
"en"
],
"clientPackageManager": "yarn",
"skipClient": true
}
}
Gateway app config
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.app.gw",
"nativeLanguage": "es"
},
"jhipsterVersion": "4.13.3",
"baseName": "gwApp",
"packageName": "com.agriket.chat",
"packageFolder": "com/app/gw",
"serverPort": "9085",
"authenticationType": "uaa",
"uaaBaseName": "UAA",
"cacheProvider": "hazelcast",
"enableHibernateCache": true,
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSocialSignIn": false,
"enableSwaggerCodegen": false,
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "gateway",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "es",
"languages": [
"es",
"en"
]
}
}
Client Code
package com.uaa.auth.service.restClient;
import com.uaa.auth.service.restClient.Contact;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = "gwApp")
@RequestMapping("/api")
public interface ContactClient {
@PostMapping("/contacts")
Contact createContact(@RequestBody Contact contact);
@GetMapping("/contacts/{id}")
Contact getContact(@PathVariable(name = "id") Long id);
}
Contact
public class Contact {
private Long id;
private String login;
private String firstName;
private String lastName;
public Contact(User user) {
this.id = user.getId();
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
}
public Long getId() {
return id;
}
public String getLogin() {
return login;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}