Hi I have a route that can have multiple servers...
I have tried the following to no luck:
zuul.routes.example.path=/example/**
zuul.routes.example.serviceId=example
example.ribbon.eureka.enabled=false
example.ribbon.eureka.listOfServers=http://127.0.0.1/metrics,http://127.0.0.1/info
This just returns the following error:
Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: example
I am using eureka for most routes, but for this one in particular I cannot use eureka.
Is it possible to get zuul to loadbalance between the two urls?
Solved
The answer below solves this issue with config, however I would mention I was using spring-boot-starter-parent, I also had to upgrade the dependency management to Camden.SR7
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<!-- <version>Brixton.SR5</version> -->
<version>Camden.SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Yes, you can. Try the following properties instead of yours.
zuul.routes.example.path=/example/**
zuul.routes.example.serviceId=example
example.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
example.ribbon.listOfServers=http://127.0.0.1/metrics,http://127.0.0.1/info
Related
Jaeger traces to spring-boot application are not able to capture traces for the DB calls made using spring-data. All other calls like RESTTemplate are able to have the traces captured.
Using springboot version 2.2.2.RELEASE and added below jaeger dependencies,
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-web-starter</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-jdbc</artifactId>
<version>0.2.11</version>
</dependency>
Any additional dependencies are missing here?
Remove your dependencies and use the following one that will include also the instrumentation you need
<dependency>
<groupid>io.opentracing.contrib</groupid>
<artifactid>opentracing-spring-jaeger-cloud-starter</artifactid>
<version>3.2.0</version>
</dependency>
I have configured JavaMelody in my application and its working fine with one instance and returning all the required graph and stats when I hit {domain-url}/monitoring but actual problem comes when I deployed my application on multi ageing environment(AWS EC2 load balancer) and suppose if I have 3 (server Ips: 10.45.120.10, 10.45.120.11 and 10.45.120.103) instance there then when I call {domain-url}/monitoring it shows once instance(server Ip 10.45.120.10) stats and graphs and when I re-hit {domain-url}/monitoring it display another instance(Server Ip 10.45.120.11) stats and graphs and so on.
Is there any way to view aggregate stats and graphs from all instance in one page on one hit {domain-url}/monitoring
Javamelody dependencies is below
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-spring-boot-starter</artifactId>
<version>1.81.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
and my application.properties for javamelody
javamelody.enabled=true
javamelody.init-parameters.log=true
javamelody.spring-monitoring-enabled=true
javamelody.init-parameters.url-exclude-pattern=(/webjars/.*)
javamelody.init-parameters.authorized-users= user:mypass
javamelody.init-parameters.monitoring-path= /monitoring
javamelody.obsolete-graphs-days=60
javamelody.obsolete-stats-days=60
Note: when I am using javamelody.init-parameters.storage-directory=/opt/myapp then no stats is displaying
P.S. I am using maven spring boot 2.1.1, Java11, javamelody 1.81.0 and my application is restful only.
I have an Eureka Server where I want to register a very basic SpringBoot service. Unfortunately the service doesnt register although I tried to follow all the articles I could find.
Moreover when I check description of the DiscoveryClient (that gets autowired), I see "Spring Cloud No-op DiscoveryClient" which suggests (as per NoopDiscoveryClient.java source) that Eureka client library isnt found.
In pom I have
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
</dependency>
which if I am right should make sure that proper netflix libraries are in place. #EnableEurekaClient annotation is present. No errors on the console when starting the client, nothing interesting in the Eureka Server console logs.
This is the configuration from the application.yml:
eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://127.0.0.1:8761}/eureka/
Any suggestions are really welcomed as I am running out of ideas :)
http://start.spring.io is your friend. You need to use the starters.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.M5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
and
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
Except #spencergibb's answer, in my case it also require <spring-cloud.version> inside the <properties>:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.M3</spring-cloud.version>
</properties>
When using embedded jetty and started via
mvn jetty:run
The following exception is thrown:
Exception in thread "main" java.util.ServiceConfigurationError:
org.apache.juli.logging.Log: Provider org.eclipse.jetty.apache.jsp.JuliLog not a subtype
Here is the pom.xml snippets:
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-websocket</artifactId>
<version>8.1.19.v20160209</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.19.v20160209</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.6</version>
</dependency>
Any pointers to a correctly configured embedded jetty (preferably also using websockets) appreciated.
Don't try to enable everything all at once.
Jetty is a highly modular system, you can pick and choose what you want to run. Nothing is mandatory by default, even the Server!
If you want examples of embedded jetty with websockets, consider reviewing the example projects that the Jetty project has put together at ...
https://github.com/jetty-project/embedded-websocket-echo-examples
Some advice:
Build up your requirements layer by layer
Start with basic websocket endpoint functionality (get this working first!)
then add slf4j + logback. (be sure you use an appropriate version, see the <scope>optional</scope> dependencies present in your previous layer before you choose a version of slf4j or logback). Test this like there is no tommorrow.
then add jsp support (as your error seems to indicate your desire for jsp support)
I'm struggling to get a simple cxf:rsServer to listen on a port.
My appContext:
<bean id="transformer" class="com.xyxx.portlistener.services.Transformer">
</bean>
<cxf:rsServer id="pushServer"
address="tcp://localhost:9090/hrm/hrm_push?bindingStyle=SimpleConsumer;resourceClasses=com.xyxx.portlistener.services.Transformer" >
<cxf:serviceBeans>
<ref bean="transformer" />
</cxf:serviceBeans>
</cxf:rsServer>
<!-- Camel Configuration -->
<camel:camelContext id="camel-1" xmlns="http://camel.apache.org/schema/spring">
<package>com.xyxx.portlistener.services</package>
<camel:route id="route1">
<camel:from uri="cxfrs://bean://pushServer"/>
<camel:to uri="log:TEST?showAll=true" />
</camel:route>
</camel:camelContext>
My exception:
MethodInvocationException: Property 'serviceBeans' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
My camel version 2.4.0 pom.xml:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-hl7</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mina</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>${camel.version}</version>
</dependency>
3 confusing issues with HTTP and that exception
I'm running camel as standalone so I don't think I need a Servlet.
pushServer is using tcp:// not http:/
transformer is a pojo and knows nothing about HTTP
Question: In most of the xml examples regarding cxf:rsServer I've seen jaxrs:server configured. That is one thing I do not have. Do I need it?
Thanks for reading. All suggestions are welcome.
Andrew
The jaxrs:server shown in the examples is simulating a remote REST web service to complete the routing example.
Route From: cxf:rsServer
Route To: cxf:rsClient
The CXF RS client needs to send the message somewhere, which is what the JAX RS server running on a different port is used for.
Since your route destination above is something else (a log component) you have no need for the JAX RS server configuration.