JMS Cache coordination [message #1059565] |
Mon, 20 May 2013 09:40  |
Eclipse User |
|
|
|
We are trying to implement JMS Cache coordination in our application by using MDBs in a clustered Websphere Application Server environment.
When we update or insert an object we see that the MDB message includes an object of type MergeChangeSetCommand and not RemoteCommand.
We are trying the code below, but the object is not of the type RemoteCommand; Is that expected?
Can someone please guide us on the correct usage?
Thanks for the help.
public void onMessage(Message message)
{
try {
if(message instanceof ObjectMessage) {
ObjectMessage objectmessage = (ObjectMessage)message;
java.io.Serializable serializable = objectmessage.getObject();
if(serializable instanceof RemoteCommand) {
((RemoteCommand)serializable).execute((
AbstractSession)getSession(), null);
}
}
}
|
|
|
|
|
|
|
|
|
|
|
Re: JMS Cache coordination [message #1061695 is a reply to message #1061686] |
Mon, 03 June 2013 10:06   |
Eclipse User |
|
|
|
I am executing the following steps to verify cache coordiantion.
Step 1 : Execute the following steps on Server 2:
final NoteBO note = entityManager.find(NoteBO.class, key);
System.out.println("Desciption " + note.getNote());
Step 2 : Execute the following steps on Server1:
final NoteBO note = entityManager.find(NoteBO.class, key);
System.out.println("Old Desciption " + note.getNote());
final Random rand = new Random();
note.setNote("Test (" + rand.nextInt(100) + ") - ");
entityManager.getTransaction().begin();
entityManager.merge(note);
entityManager.getTransaction().commit();
After the enity has committed on server1, eclipselink has sent a JMS message with the changes.
Step 3 : Execute the following steps after JMS message has processed on Server 2:
final NoteBO note = entityManager.find(NoteBO.class, key);
System.out.println("Desciption " + note.getNote());
In Step 3, I can see the same old description value (i.e. same as in Step 1) of Note entity. When I debugged, I found that the following line is always returing null value within MergeManager.mergeChangesFromChangeSet(UnitOfWorkChangeSet) method.
Object object = objectChangeSet.getTargetVersionOfSourceObject(this, this.session, false);
if (object != null) {
mergeChanges(object, objectChangeSet, this.session);
.....
That's why mergeChanges method has never invoked. Is there anything, I am doing wrong?
|
|
|
Re: JMS Cache coordination [message #1061756 is a reply to message #1061695] |
Mon, 03 June 2013 15:01  |
Eclipse User |
|
|
|
objectChangeSet.getTargetVersionOfSourceObject(this, this.session, false) attempts to get the object from the cache. If it is returning null, then there is nothing to merge into. Is your Server 2 operating within a transaction when it is performing find in step 1? Try clearing the EntityManager using em.clear() before attempting the find in step 3 - it should go to the shared cache or database for the entity.
|
|
|
Powered by
FUDForum. Page generated in 0.06048 seconds