[jboss-user] [JBoss Cache POJO Edition] New message: "Replication: simplest assumption not working ... with source code ..."
Ulrich Staudinger
do-not-reply at jboss.com
Thu Jan 14 11:03:16 EST 2010
User development,
A new message was posted in the thread "Replication: simplest assumption not working ... with source code ...":
http://community.jboss.org/message/520095#520095
Author : Ulrich Staudinger
Profile : http://community.jboss.org/people/ustaudinger
Message:
--------------------------------------------------------------
Hi there,
I want to use the replication of objects. Unfortunately I do not get it running properly.
I have one server, to which multiple clients connect over JGroups/TCP.
The following classes are the code I use.
Problem description:
The initial lookup in the client succeeds and it contains a snapshot of object when the lookup occured. Later set calls on the server are not updating the object on the client side.
However, when decomment in the server spot [1] and move in the client the find into the loop, then I see that it works.
???
Any help appreciated. I somehow have the impression that the client state is not transferred ...
Thanks,
Ulrich
The Server app:
@PojoCacheListener
public class JbossCacheLayer
{
private transient Cache cache;
private transient CacheModelDelegate cacheModelDelegate;
private transient Node root;
private TransactionManager txManager;
private transient Transaction tx;
private Quotes quotes = new Quotes();
@Attached
public void handleAttached(AttachedEvent event)
{
System.out.println("Attached = " + event.getSource());
}
@Attached
@Detached
@FieldModified
@ListModified
@MapModified
@SetModified
@TransactionRegistered
@TransactionCompleted
public void handleAll(Event event)
{
System.out.println(event);
}
@NodeCreated
public void handleNodeCreated(NodeCreatedEvent event)
{
System.out.println(event);
}
@NodeRemoved
public void handleNodeRemoved(NodeRemovedEvent event)
{
System.out.println(event);
}
@NodeModified
public void handleNodeModified(NodeModifiedEvent event)
{
System.out.println(event);
}
@NodeEvicted
public void handleNodeEvent(NodeEvictedEvent event)
{
System.out.println(event);
}
public JbossCacheLayer()
throws Exception
{
PojoCache pc = PojoCacheFactory.createCache("replSync.xml", true);
pc.addListener(this);
pc.addListener(this, Pattern.compile("pojos/quotes"));
Quotes q = new Quotes();
pc.attach(Fqn.fromString("pojos/quotes"), q);
q = (Quotes)pc.find(Fqn.fromString("pojos/quotes"));
List list = q.getQuotes();
//cache.put(Fqn.fromString("Test"+Math.random()), null);
while(true)
{
q.getQuotes().add("TEST");
q.setRand(Math.random());
// [1] pc.attach(Fqn.fromString("pojos/quotes"), q);
Thread.sleep(1000);
}
}
public static void main(String[] args)
throws Exception
{
new JbossCacheLayer();
}
}
The client app:
public class JbossCacheClient
{
public JbossCacheClient()
throws Exception
{
PojoCache pc = PojoCacheFactory.createCache("replSync.xml", true);
Quotes q = (Quotes)pc.find(Fqn.fromString("pojos/quotes"));
while(true)
{
System.out.println(q.getRand());
System.out.println(q.getQuotes().size());
Thread.sleep(1000);
}
}
public static void main(String[] args) throws Exception
{
new JbossCacheClient();
}
}
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520095#520095
More information about the jboss-user
mailing list