Archived
This forum has been archived. Please start a new discussion on GitHub.
Synchronize object on nodes
Hi,
I'm writing a Distributed Message Queue with 2 functions: Publish and Subscribe. Few days ago i encountered a problem because after a successful publish operation on one service the new message is need to be replicated on all other nodes running this application.
So my question is: Is there a possibility to synchronize object's on different nodes? I will only add that both adapter's are in one replica group so the registry should be replicated on the second node. Code that creates adapters:
To send this message to one node but I'm getting NullReferenceExcetpion. Any idea how to run publish on all nodes in App?
Below node config:
Thanks for help
Cheers,
Fabian
I'm writing a Distributed Message Queue with 2 functions: Publish and Subscribe. Few days ago i encountered a problem because after a successful publish operation on one service the new message is need to be replicated on all other nodes running this application.
So my question is: Is there a possibility to synchronize object's on different nodes? I will only add that both adapter's are in one replica group so the registry should be replicated on the second node. Code that creates adapters:
public class DMQServer : IceBox.Service { DMQI dmqi; public DMQServer () { } private Ice.ObjectAdapter _adapter; public void start (string name, Ice.Communicator communicator, string[] args) { dmqi = new DMQI(); _adapter = communicator.createObjectAdapter (name); _adapter.@add (dmqi, Ice.Util.stringToIdentity ("DMQ")); _adapter.activate (); }I've already tried this:
public override void Publish (string topic, string message, Ice.Current current__) { Ice.Communicator com = current__.adapter.getCommunicator(); Ice.ObjectPrx prx = com.stringToProxy("DMQInstance/Locator -t:tcp -h 127.0.0.1 -p 4061"); DistributedMessagesQueuePrx dmq = DistributedMessagesQueuePrxHelper.checkedCast(prx); dmq.Publish(topic,message); /// NullReferenceException AddElementToDistibutedMessageQueue (topic, null, message); }
To send this message to one node but I'm getting NullReferenceExcetpion. Any idea how to run publish on all nodes in App?
Below node config:
Node1.cfg IceGrid.InstanceName=DMQInstance IceGrid.Registry.Client.Endpoints = tcp -h 127.0.0.1 -p 4061 IceGrid.Registry.Server.Endpoints = tcp -h 127.0.0.1 IceGrid.Registry.Internal.Endpoints = tcp -h 127.0.0.1 IceGrid.Registry.AdminPermissionsVerifier = DMQInstance/NullPermissionsVerifier IceGrid.Registry.Data = tmp/registry #IceGrid.Registry.DynamicRegistration = 1 IceGrid.Node.Endpoints = tcp IceGrid.Node.Name = Node1 IceGrid.Node.Data = tmp/node1 Ice.Default.Locator = DMQInstance/Locator:tcp -h 127.0.0.1 -p 4061:tcp -h 127.0.0.1 -p 4062 IceGrid.Node.CollocateRegistry = 1 Ice.Default.LocatorCacheTimeout=0 Node2.cfg #IceGrid.Registry.DynamicRegistration=1 IceGrid.Registry.ReplicaName=Node2Recplica IceGrid.Registry.Client.Endpoints=tcp -h 127.0.0.1 -p 4062 IceGrid.Registry.Server.Endpoints=tcp -h 127.0.0.1 IceGrid.Registry.Internal.Endpoints=tcp -h 127.0.0.1 IceGrid.Registry.Data=tmp/registry2 Ice.Default.LocatorCacheTimeout=0 Ice.Default.Locator = DMQInstance/Locator:tcp -h 127.0.0.1 -p 4061:tcp -h 127.0.0.1 -p 4062 IceGrid.Node.Endpoints = tcp -h 127.0.0.1 IceGrid.Node.Name = Node2 IceGrid.Node.Data = tmp/node2 IceGrid.Node.CollocateRegistry=1
Thanks for help
Cheers,
Fabian
0
Comments
-
Hi Fabian,
Welcome to our forums!So my question is: Is there a possibility to synchronize object's on different nodes? I will only add that both adapter's are in one replica group so the registry should be replicated on the second node.
I don't understand what you're trying to do. If you want to send the same request to multiple servers, you can simply send this request multiple times, or use the IceStorm service.
Also, note this is totally unrelated to IceGrid registry replication. IceGrid registry replication just ensure IceGrid keeps running even in the event a registry replica crashes or becomes unavailable. This is independent of whether or not you replicate your own servers using IceGrid.Ice.ObjectPrx prx = com.stringToProxy("DMQInstance/Locator -t:tcp -h 127.0.0.1 -p 4061"); DistributedMessagesQueuePrx dmq = DistributedMessagesQueuePrxHelper.checkedCast(prx);
You get a null proxy here because DMQInstance/Locator is a Ice::Locator, and not a DistributedMessageQueue object.
Best regards,
Bernard0