Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opentracing JMSTracingTemplate do not have the setting of JMSTemplate of spring boot #31

Open
lucapreziati opened this issue Jul 23, 2019 · 5 comments

Comments

@lucapreziati
Copy link
Contributor

The OpenTracing starter with the configuration of JmsTemplate do not consider the setting properties related to spring-boot jms starter.

@lucapreziati
Copy link
Contributor Author

As first step i think it is necessary adding @ConditionalOnMissingBean on configuration to create bean, to provide opportunity to made override of the declared Bean, but i think it is necessary find a solution to get the configuration of spring boot jms and put into JmsTracingTemplate.

At the moment i add in my project configuration bean this method, taken partially from org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration configuration:


@Bean ( name = "tracedJMSTemplate")
	@Primary
//	@ConditionalOnMissingBean
//	@ConditionalOnSingleCandidate(ConnectionFactory.class)
	public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory, io.opentracing.Tracer tracer,
			JmsProperties properties, ObjectProvider<DestinationResolver> destinationResolver,
			ObjectProvider<MessageConverter> messageConverter) {
		PropertyMapper map = PropertyMapper.get();
		JmsTemplate template = new TracingJmsTemplate(connectionFactory, tracer);
		template.setPubSubDomain(properties.isPubSubDomain());
		map.from(destinationResolver::getIfUnique).whenNonNull().to(template::setDestinationResolver);
		map.from(messageConverter::getIfUnique).whenNonNull().to(template::setMessageConverter);
		mapTemplateProperties(properties.getTemplate(), template);
		return template;
	}

	private void mapTemplateProperties(Template properties, JmsTemplate template) {
		PropertyMapper map = PropertyMapper.get();
		map.from(properties::getDefaultDestination).whenNonNull().to(template::setDefaultDestinationName);
		map.from(properties::getDeliveryDelay).whenNonNull().as(Duration::toMillis).to(template::setDeliveryDelay);
		map.from(properties::determineQosEnabled).to(template::setExplicitQosEnabled);
		map.from(properties::getDeliveryMode).whenNonNull().as(DeliveryMode::getValue).to(template::setDeliveryMode);
		map.from(properties::getPriority).whenNonNull().to(template::setPriority);
		map.from(properties::getTimeToLive).whenNonNull().as(Duration::toMillis).to(template::setTimeToLive);
		map.from(properties::getReceiveTimeout).whenNonNull().as(Duration::toMillis).to(template::setReceiveTimeout);
	}

@malafeev
Copy link

for me it looks like a solution to use @Primary to avoid adding dependency on spring boot.

@malafeev
Copy link

or we can create a new maven module opentracing-jms-spring-boot which will depend on opentracing-jms-spring and spring-boot-autoconfigure and provide required functionality.

@lucapreziati
Copy link
Contributor Author

can be better have a second module,, I have to check if in this manner we can also try to get all the spring boot properties.

I will check.

@klopfdreh
Copy link

I also ran into the same issue. I guess in most of the current cloud scenarios docker and spring boot is used, so I would be very pleased if this could be fixed. The idea of adding a new module which connects the jmstemplate default properties of spring boot with the creation of the jaeger tracing template is the best way I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants