troubleshooting Question

Spring multithreading issue

Avatar of royjayd
royjayd asked on
Java
2 Comments1 Solution197 ViewsLast Modified:
Dear experts

I am facing a multi threading issue in our spring environment.

In spring-config.xml we have
<bean id="jaxbConversionManager" class="com.junta.util.JAXBConversionManager"/>


JAXBConversionManager.java has unmarshal method
public class JAXBConversionManager{
	@SuppressWarnings("unchecked")
	public <T> T unmarshal(Document msg) {
		//convert from xml to object and return 
	}
	}
     
      
I have two classes
	public Class1 implements MessageListener{
	@Autowired
	private JAXBConversionManager jaxbConversionManager;
	
	private void method1(Document message)  throws Exception {
		Customer customer = jaxbConversionManager.unmarshal(message);
		LOGGER.info("Customer object1 is", customer.toString());
		moveForward(customer);
		}
	}
	
	public Class2 implements MessageListener{
	@Autowired
	private JAXBConversionManager jaxbConversionManager;
	
	private void method2(Document message) throws Exception {
		Customer customer = jaxbConversionManager.unmarshal(message);
		LOGGER.info("Customer object2 is", customer.toString());
		moveForward(customer);
	}
	}
     
      both above classes are using jaxbConversionManager object.
      
      Document message passed to method1() from Class1 was actually visible in Class2.method2() , i was able to confirm that in the log statement
      LOGGER.info("Customer object2 is", customer.toString()); --> prints message which came to method1
      
      This is most probably because jaxbConversionManager is not threadsafe. Any idea how i can make it threadsafe in a spring way.
      
      
      Thanks
ASKER CERTIFIED SOLUTION
mccarl
IT Business Systems Analyst / Software Developer
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros