Using remote RabbitMQ server - spring

How to use remote RabbitMQ server rather than local host in spring project?
For example if I have the following rabbitmq remote server: https://abc.xyz.com, how can I edit the application.properties
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

Related

Eureka client registration with external git repo configuration files

I have an external configuration repository on git containing all my propertie files.
My eureka client is microservice-order with this application file :
spring.application.name=microservice-order
spring.config.import=configserver:http://localhost:9101
This application file point to "microservice-order" propertie files :
server.port=9001
spring.data.mongodb.uri=mongodb+srv://admin:************#cluster0.yqhwqrj.mongodb.net/Facebouffe?retryWrites=true&w=majority
#configurations
configs.setOrderLimit= 5
#eureka
spring.application.name = microservice-order
eureka.client.serviceUrl.defaultZone: http://localhost:9102/eureka/
My eureka server has this propertie file :
spring.application.name=eureka-server spring.config.import=configserver:http://localhost:9101
pointing to exteral repo file "eureka-server.properties":
`
server.port= 9102
eureka.client.serviceUrl.defaultZone = http://localhost:9102/eureka/
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
spring.cloud.config.import-check.enabled=false`
I wrote "#EnableEurekaServer" (eureka-service-discovery) for server class and "#EnableEurekaClient" for client class (microservice-order)
When i start configserver, its running on 9101 port
When i start eureka-service-discovery, its running on 9102 port
When i start microservice-order, its running on 9001 port
So, each class load its own propertie files, but when i connect to http://localhost:9102/ , there is no service registered.
Do you have any idea ?
thank you !
I'm trying to register an eureka client to eureka server with external propertie files repository on github.

Spring cloud client trying to run on server port 8888

The config server is up and the client is able to fetch the properties from config server.
HTTP GET http://localhost:8888/account-service/dev/config
Accept=[application/json, application/*+json]
Response 200 OK
But the problem is, client service is trying to start on config server port 8888. I have set server.port=8080 in the client but still not working.
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8888 was already in use.
Am I missing any configuration here? Highly appreciate any help.
Config server application.properties,
spring.application.name=config-server
spring.cloud.config.profiles=dev
spring.cloud.config.server.git.uri=REPO_URL
server.port=8888
Finally, I was able to find the solution. When I was trying to start client service, server.port was also getting overridden with config server port. I added server.port=8080 in the properties file for the client service profile in config repo (account-service.properties) and it worked.

Eureka Client: Eureka Registry server address alternative to 'localhost'

Eureka-server(MediaStoreEurekaServer): bootstrap.properties
spring.application.name=MediaStoreEurekaServer
server.port=9091
eureka.client.serviceUrl.defaultZone=http://localhost:9091/eureka}
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
Eureka-client(Config-Server): bootstrap.properties
spring.application.name=Config-Server
server.port=9093
user.home=${HOME}
spring.cloud.config.server.native.search-locations=file://${user.home}/IdeaProjects/MediaStore/centralProperties
spring.profiles.active=native
eureka.client.serviceUrl.defaultZone=http://localhost:9091/eureka
With above 2 properties (services running on same machine), Config-Server is able to register with MediaStoreEurekaServer eureka registry server when using http://localhost:9091/eureka.
I don't want to use localhost. When I use http://MediaStoreEurekaServer:9091/eureka , Config-Server is not able to register.
Can we use something other than localhost for eureka client to find the eureka server like service or instance name? when services are running on same host
Edit 1:
This is what eureka client spring logs give when in eureka client properties file i set
eureka.client.serviceUrl.defaultZone=http://MediaStoreEurekaServer:9091/eureka
Error:
2020-05-22 20:01:02.137 ERROR 22846 --- [nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://MediaStoreEurekaServer:9091/eureka/}
com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: MediaStoreEurekaServer```

How to run spring boot application multiple instance when get resource from config server?

I have Eureka server, Eureka zuul and config server.
So I write a simple microservice. Then, running on 8686 port.
So I want to run that microservice on another port.
I trying that command. But don't work.
java -Dserver.port=8687 -jar -Dlogging.file="bla.log" testMicro.jar --debug > "bla.log"&
I am confusing. Help me!
You have two ways to running your instances on different ports.
user assignment of random port from a specified range:
server:
port: ${random.int(8080,8090)}
Set in property file from config server for testMicro microservice the following configurations:
spring:
cloud:
config:
override-system-properties: false
allow-override: true
override-none: true
and then run again your jar with -Dserver.port=8687 property

How to register a service using Spring Cloud Consul

I have registered a service using Spring Cloud Consul, but for this I had to run a Consul local agent which establishes a channel communication to Consul server node (running as bootstrap).
For example:
#Server
consul agent -server -bootstrap -bind -data-dir data -ui-dir web_ui
#Desktop
consul agent -data-dir consul -ui-dir consul/dist -join server_ip_address
Is there any way to avoid of having this local agent in my desktop, I mean from my desktop Spring Cloud Consul would register the service to server node?
An example of this is what Netflix Eureka client does with Netflix Eureka server, no external agents running in machines to bind services names.
you have to use property file or yaml file i just give sample yaml file
application.yml
# Configure this Discovery Server
spring:
cloud:
consul:
host: localhost
port: 8500
bootstrap.yml
spring:
application:
name: service-name

Resources