Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Jms Transaction and Threads

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team
I Have a main thread which will poll the messages from the Queue
and create a child thread to process it .The requirement is Both the parent and the child should be in one transaction unit.
Here is my application config.


Code for M1GenericConnector

Code For ConnectorTask


public class QueueUtility {

private JmsTemplate jmsTemplate;

public JmsTemplate getJmsTemplate() {
return jmsTemplate;
}

public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
this.jmsTemplate.setReceiveTimeout(1500);
}

public Message retrive(final String destinationName){
return jmsTemplate.receive(destinationName);
}

public void sendMessage(final String destinationName ,final String message){
jmsTemplate.convertAndSend(destinationName, message);
}

public void sendMessage(final String destinationName ,final Map<String,Object> message){
jmsTemplate.send(destinationName, new MessageCreator() {

@Override
public Message createMessage(Session arg0) throws JMSException {
// TODO Auto-generated method stub
MapMessage mapmessage = arg0.createMapMessage();
for (Map.Entry<String, Object> entry : message.entrySet()) {
mapmessage.setObjectProperty(entry.getKey(), entry.getValue());
}
return mapmessage;
}
});
}

}
[/CODE]

Code for M1OperatorLoader


But the Poblem is in the Queue there were 5 messages each messages DEST_ID value is 0 ,1,2,3 respectively.So according to the program two messages should be rollback and remain should poll off from queue(commited)
But when i run this program no message get off from the in bound queue....
Please help me out what is the actual problem in my code
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic