Closed astik closed 5 years ago
Can't you just change the name of the configuration?
sorry I think I should have deleted that branch! the only branches intended to be used are in the readme. this one was made before sleuth already supported jms
On Wed, Aug 7, 2019, 11:47 PM Romain Gonord notifications@github.com wrote:
Hi,
When trying the add-jms-tracing branch, i've got this issue at startup for both application (backend and frontend) :
APPLICATION FAILED TO START
Description:
The bean 'configureTracing', defined in class path resource [org/springframework/cloud/sleuth/instrument/messaging/TraceMessagingAutoConfiguration$SleuthJmsConfiguration.class], could not be registered. A bean with that name has already been defined in sleuth.webmvc.JmsTracingConfiguration and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Adding this configuration inside application.properties makes it work :
spring.sleuth.messaging.jms.enabled=false
I was wondering if this is the way to go or maybe if sleuth.version is outdated (2.1.0.BUILD-SNAPSHOT on this branch and 2.1.2.RELEASE on master).
I have tested with no change on code, only modifications on application.properties :
- spring.activemq.broker-url to match my broker url
- spring.zipkin.baseUrl to match my zipkin url
- spring.sleuth.messaging.jms.enabled=false to turn off the error as startup
With this, i'm able :
- to send message to the queue after calling frontend api
- to observe the message reaching the queue (active mq from docker webcenter/activemq)
- to observe producer processing the message
- to observe beautiful graphic into zipkin
Also, i don't know if it is normal or not but my message get processed twice.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openzipkin/sleuth-webmvc-example/issues/25?email_source=notifications&email_token=AAAPVV7IMLNBVU2ODDBZYELQDLVCRA5CNFSM4IKB26KKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HD52OSA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAPVV33NFXTL27XJ6NTNL3QDLVCRANCNFSM4IKB26KA .
Ok, so i try working with minimum code to make it communicate from frontend to message queue and then from message queue to backend. Here are the results (starting with master branch as reference - commit id 8f45c78) :
package sleuth.webmvc;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@EnableAutoConfiguration
@RestController
@CrossOrigin // So that javascript can be hosted elsewhere
@EnableJms
public class Frontend {
@Autowired JmsTemplate jmsTemplate;
@RequestMapping("/") public void callBackend() {
jmsTemplate.convertAndSend("backend", new Date());
}
public static void main(String[] args) {
SpringApplication.run(Frontend.class,
"--spring.application.name=frontend",
"--server.port=8081"
);
}
}
package sleuth.webmvc;
import javax.jms.Message;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.web.bind.annotation.RestController;
@EnableAutoConfiguration
@RestController
@EnableJms
public class Backend {
@JmsListener(destination = "backend")
public void onMessage(Message m) {
System.err.println(m);
}
public static void main(String[] args) {
SpringApplication.run(Backend.class,
"--spring.application.name=backend",
"--server.port=0" // so that multiple consumer can run on the same server
);
}
}
Inside pom.xml, i just add :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
In application.properties, i add 2 parameters to connect to my environment (zipkin and message queue) :
spring.activemq.broker-url=tcp://p-nan-roseau:61616
spring.zipkin.baseUrl: http://p-nan-roseau:9411/
That's all ! It's amazing as simple it is to make everything work together. Great job there ! Thanks a lot.
thanks for closing the loop and glad it is working out!
On Thu, Aug 8, 2019, 5:43 PM Romain Gonord notifications@github.com wrote:
Ok, so i try working with minimum code to make it communicate from frontend to message queue and then from message queue to backend. Here are the results (starting with master branch as reference - commit id 8f45c78 https://github.com/openzipkin/sleuth-webmvc-example/commit/8f45c78626f58b6bc7f7a57faa920fd7beb83619) :
package sleuth.webmvc; import java.util.Date; import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.jms.annotation.EnableJms;import org.springframework.jms.core.JmsTemplate;import org.springframework.web.bind.annotation.CrossOrigin;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController; @EnableAutoConfiguration@RestController@CrossOrigin // So that javascript can be hosted elsewhere@EnableJmspublic class Frontend {
@Autowired JmsTemplate jmsTemplate;
@RequestMapping("/") public void callBackend() { jmsTemplate.convertAndSend("backend", new Date()); }
public static void main(String[] args) { SpringApplication.run(Frontend.class, "--spring.application.name=frontend", "--server.port=8081" ); } }
package sleuth.webmvc; import java.util.Date; import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.jms.annotation.EnableJms;import org.springframework.jms.annotation.JmsListener;import org.springframework.web.bind.annotation.RestController; @EnableAutoConfiguration@RestController@EnableJmspublic class Backend {
@JmsListener(destination = "backend") public void onMessage() { System.err.println(new Date().toString()); }
public static void main(String[] args) { SpringApplication.run(Backend.class, "--spring.application.name=backend", "--server.port=9000" ); } }
Inside pom.xml, i just add :
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-activemq</artifactId> </dependency>
In application.properties, i add 2 parameters to connect to my environment (zipkin and message queue) :
spring.activemq.broker-url=tcp://p-nan-roseau:61616 spring.zipkin.baseUrl: http://p-nan-roseau:9411/
That's all ! It's amazing as simple it is to make everything work together. Great job there ! Thanks a lot.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/openzipkin/sleuth-webmvc-example/issues/25?email_source=notifications&email_token=AAAPVV7NHSUFIGOFBUMLKADQDPTDBA5CNFSM4IKB26KKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD33CMBA#issuecomment-519448068, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAPVV4ULDGH6P5FAWEHELTQDPTDBANCNFSM4IKB26KA .
Even if it is a very simple use cas, i think it would be interesting to have it in this example project =)
Also, i think it would be easier to have it as a monorepo instead of branch, it would be easier to test new version for spring, sleuth, zipkin.
this being an example and all want to resist temptation to do too much here as we have tons of things to manage as it is. you can imagine how big a repo that would become.. also diff is important to visualize the small changes.
on this JMS part though.. if you want you can raise PR to change the branch here including readme update (with image) then we can make your work the default on the jms branch changing it from accident to official
On Thu, Aug 8, 2019, 5:47 PM Romain Gonord notifications@github.com wrote:
Even if it is a very simple use cas, i think it would be interesting to have it in this example project =)
Also, i think it would be easier to have it as a monorepo instead of branch, it would be easier to test new version for spring, sleuth, zipkin.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/openzipkin/sleuth-webmvc-example/issues/25?email_source=notifications&email_token=AAAPVV4MJAIITBKJZ7YR6HTQDPTSJA5CNFSM4IKB26KKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD33CWWA#issuecomment-519449432, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAPVV2OZVE76WCYCVUYYDDQDPTSJANCNFSM4IKB26KA .
Hi,
When trying the add-jms-tracing branch, i've got this issue at startup for both application (backend and frontend) :
Adding this configuration inside application.properties makes it work :
I was wondering if this is the way to go or maybe if sleuth.version is outdated (2.1.0.BUILD-SNAPSHOT on this branch and 2.1.2.RELEASE on master).
I have tested with no change on code, only modifications on application.properties :
With this, i'm able :
Also, i don't know if it is normal or not but my message get processed twice.