Skip to content

Using this library you can connect clients with Eureka Discovery Server using MicroProfile

Notifications You must be signed in to change notification settings

gdiazs/microprofile-eureka-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

microprofile-eureka-client

Using this library you can connect clients with Eureka Discovery Server using MicroProfile

Create a MicroProfile microservice

https://start.microprofile.io/

Compile this project

mvn clean install

Add to the Microprofile Project POM the next dependency:

 <dependency>
   <groupId>io.github.gdiazs</groupId>
   <artifactId>microprofile-eureka-client</artifactId>
   <version>0.0.1-SNAPSHOT</version>
 </dependency>

In the resource folder add the file eureka-client.properties

Once your eureka server it's up you should add in your JAX-RS endpoint the reference to the service and endpoint

@Path("/hello")
@Singleton
public class HelloController {

	@Inject
	@EurekaService(service = "ping.serviceName", endpoint="ping.endpoint") //must be defined in microprofile-config.properties
	private Optional<String> urlPingService;

	@GET
	public String sayHello() {

		String result = "";
		if (urlPingService.isPresent()) {
			result = ClientBuilder.newClient().target(urlPingService.get()).request(MediaType.APPLICATION_JSON)
					.get(String.class);
		}

		return result;
	}
}

About

Using this library you can connect clients with Eureka Discovery Server using MicroProfile

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages