Avatar of royjayd
royjayd
 asked on

Spring multithreading issue

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"/>

Open in new window



JAXBConversionManager.java has unmarshal method
public class JAXBConversionManager{
	@SuppressWarnings("unchecked")
	public <T> T unmarshal(Document msg) {
		//convert from xml to object and return 
	}
	}

Open in new window

     
      
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);
	}
	}

Open in new window

     
      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
Java

Avatar of undefined
Last Comment
royjayd

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mccarl

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
royjayd

ASKER
thanks
Your help has saved me hundreds of hours of internet surfing.
fblack61