How To setup multiple mail server with failover in Spring Boot? - spring-boot

Sending emails from Spring Boot is as easy as possible.
spring:
mail:
host: <servername>
Plus some additional configuration and off you go.
We rely on an internal email provider that offers two mail servers. Instead of setting these up behind a load balancer, the consumer has to manage the failover itself.
So far, we have therefore only used one of the two servers via the Spring configuration mentioned above.
If this server has a problem, such as the current one where the TLS certificate has expired 🤦‍♂️, the Rediness Check in Spring Actuator floods the log file with error messages.
Does anyone have a solution for using multiple mail servers to provide a fallback scenario?

Related

Spring Boot 2 + Websockets + Load balancer

We have written simple message sending mechanism to client (logged in user based) from server by using spring boot + websocket.
Currently its running in a single server, which is working fine.
But our production servers running under load balancing environment.
How could we achieve where the messages are pushed from server nodes send to appropriate users.
Please advice the possibilities, I have read some articles about RabbitMQ with socketjs , but not clear will it work for load balancing.
Thanks
If you have multiple instances of your websocket server, then every instance needs to know the sessions that exists on other instances.
Therefore you need to use a broker relay (not the in-memory broker given by spring) and set the UserRegistryBroadcast property.
You can find some info related to this at the end of this talk https://www.youtube.com/watch?v=nxakp15CACY

How to refresh config clients automatically?

I am new to Spring Config Server/Client technologies.
I am using a spring config server to hold some config values.
Config clients will connect to the server and get the values.
If i change some of the config values at the config server, then currently I have to refresh the clients to load the config details from config server again by invoking "/refresh" on each client.
Is there anyway the clients will be notified by the config server and they will then reload the configuration again ?
Yes there is a way.
The solution is to use the Spring Cloud Bus. Using this module, you would link multiple clients to the server using a message broker. The only message broker implementation currently supported by this module is AMQP. Once the clients are connected to the server, invoking the endpoint on the server /bus/refresh will automatically broadcast the configuration changes to all the subscribed clients. This therefore means it is possible to reload configuration changes for any number of clients with one single refresh request which originates at the server.

How to connect to remote weblogic JMS server?

I have a jms server running on weblogic and I need another application running on another server (weblogic as well) to listen to JMS topics sent by the JMS server mentioned before. The fact is that I don't know how to do that. I mean, what do I need on the consumer application side? Thansk in advance.
I know it´s a little old, but could help other people trying to achieve the same.
First you need to enable Cross-Domain Security on both domains envolved on your JMS communication. Please see specific documentation here: https://docs.oracle.com/middleware/1221/wls/SECMG/domain.htm#SECMG402
For reading a message from a JMS resource, there are a ton of examples you can search online, but basically you should rely on Weblogic´s t3 protocol. Here is a relativelly recent example using Spring Boot: Connect to remote jms queue with Spring Boot

How to run Spring Cloud Config server in Fault Tolerance mode?

In my project we have a requirement to run two instances of spring cloud config server so if one instance goes down, other will take care the config server responsibilities.
Currently, you would need to put config server behind a load balancer. It is stateless, so that wouldn't hurt. There is an open issue to configure multiple config server url's in the client, so it could do failover there.
If you are running multiple instances of the config server, you can have them all register themselves in Eureka, and maybe do a lookup to the config server with it's application name via Eureka in all the other microservices. This way, Zuul (and Ribbon) will take care of the load balancing.
Edit:
I guess spencergibb is right. It's best to use a load balancer, for eg: ELB, if you're going to deploy on AWS.
Consider multiple spring-cloud-config-uris for high availability

Zuul Autodiscovery issues

We are in the process of standing up a new microservices architecture with Zuul at the front-end and a bunch of tomcat enabled microservices at the backend. Each service as it starts up, will register itself with Eureka and any client that wants to call those service will do so through Zuul. We've got this all wired in and everything is working fine.
However, I have a couple questions as to how we can make this architecture much more dynamic.
One thing that we assumed was there out of the box with Ribbon/Eureka, but have yet to find a solution for is that as we add more services to the backend, that somehow (via Archiaus and update to Zuul's eureka-client.properties file) Zuul's Ribbon client would update itself with the new service details (e.g. vipaddress, load balancing algorithm, etc). So far, the only thing that works is to update the properties file and restart Zuul (ughhh).
For example, let's say today we have 2 microservices at the backend, therefore, Zuul's eureka/ribbon client configuration would include the below:
ribbon.client.niws.clientlist=service1|service2
zuul.ribbon.namespace=zuul.client
service1.zuul.client.DeploymentContextBasedVipAddresses=myService1
service1.zuul.client.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
service2.zuul.client.DeploymentContextBasedVipAddresses=myService2
service2.zuul.client.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
Now tomorrow, let's assume we need to add service3. What we have observed is that if we add those details to the same configuration (see below), they only become available to Zuul after a restart. Is there some other configuration parameter we are missing that would allow us to dynamically introduce the new service details or do we have to roll our own Eureka/Ribbon client to do this?
ribbon.client.niws.clientlist=service1|service2|service3
zuul.ribbon.namespace=zuul.client
service1.zuul.client.DeploymentContextBasedVipAddresses=myService1
service1.zuul.client.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
service2.zuul.client.DeploymentContextBasedVipAddresses=myService2
service2.zuul.client.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
service3.zuul.client.DeploymentContextBasedVipAddresses=myService3
service3.zuul.client.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
My other question is related and that is do we really need to add a client configuration (in eureka-client.properties) for every service that Zuul could possibly route to? At some point, we may have 100's of services running and trying to maintain all the related client configurations in Zuul seems a bit clumsy. Is there a way to globally configure Zuul to load all services into its client list from Eureka (or based on some service metadata in Eureka) and dynamically update this list as new services register themselves with Eureka?
Thanks!
The issue is with namespaces.If we use the default namespace it should be able to pick up the new properties addedd by default.

Resources