I have a method which is doing multiple operation in a transaction. On of the operation is sending message to MDB. I am using hibernate with spring framework.
Pseudo code is :
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public someMethod{
dao.update(someObject);
sendToMDB(someObjectID); << sending ID of above updated object
dao.doSomeThingMore();
}
In the MDB i am just fetching the above updatedObject :
onMessage(){
....
dao.find(someObjectID);
}
The problem I am facing is when i retrieve someObject in MDB its retrieving the old values of someObject and not the updated ones!!!
I tried to take away all me开发者_StackOverflow中文版thods in MDB and put all together in method someMethod() and it works all fine. I even tried using flush() & clear() after dao.update() but still same problem.
Please help.
Thanks in advance.
Most probably you need to create transactional queue session.
QueueSession createQueueSession(
QueueConnection qu
) throws JMSException {
return qu.createQueueSession(true, -1);
}
Note here true parameter will make session transactional. Here -1 just dummy parameter when you want to neglect acknowledgement param , you may use predefined ack modes though.
Also there may be some transactional configurations you can set in your applications server console if needed to make calls transactional.
精彩评论