Unable to register Custom QueueService with Hazelcast Client

102 views
Skip to first unread message

a.bhatt...@globallogic.com

unread,
Aug 20, 2014, 9:16:45 AM8/20/14
to haze...@googlegroups.com
There are technical challenge to register custom QueueService with hazelcast client to use it. There is no direct support with HazelCastclient to register service. Please provide a way to support it. Currently we are using hazelcast version as 3.2 for both core and client

Whenever I am trying to get the Instance of the Queue following way I get error

"No factory registered for service:xxx"

IQueue dq = client.getDistributedObject(PriorityQueueService.SERVICE_NAME, "distQ");

Note : PriorityQueueService extends QueueService

I was able to register successfully with Hz instance as a server using ServiceConfig and it works fine

final ServiceConfig serviceConfig = new ServiceConfig();
    serviceConfig.setEnabled(true);
    serviceConfig.setClassName(PriorityQueueService.class.getName());
    serviceConfig.setName(PriorityQueueService.SERVICE_NAME);


One proposed Solution to HZ as  a client and register Custom Queue is the following way. But the approach is complex and we are changing the core class of HZ client. Is there any other solution or version of HZ I can use for a better solution

1) Create a new HazelCastClient as MyClient ( we cannot extend HazelCastClient as it is final class) 
2) Overload method and register the new service with ProxyManager 

  @Override
    public <T extends DistributedObject> T getDistributedObject(String serviceName, String name,ClientProxyFactory factory) {
       //proxyManager.register(serviceName,factory);
        return (T) proxyManager.getProxy(serviceName, name);
    }

Mehmet Dogan

unread,
Aug 21, 2014, 7:21:46 AM8/21/14
to haze...@googlegroups.com
This is not well documented but you can register a proxy factory using ClientConfig;

ClientConfig clientConfig = new ClientConfig();
ProxyFactoryConfig proxyFactoryConfig = new ProxyFactoryConfig();
proxyFactoryConfig.setService(SERVICE_NAME);
proxyFactoryConfig.setClassName(CustomProxyFactory.class.getName());
clientConfig.addProxyFactoryConfig(proxyFactoryConfig);

HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
String objectName = "custom-object";
CustomClientProxy proxy = client.getDistributedObject(SERVICE_NAME, objectName);


private static class CustomProxyFactory implements ClientProxyFactory {

    @Override
    public ClientProxy create(String id) {
        return new CustomClientProxy(SERVICE_NAME, id);
    }
}

private static class CustomClientProxy extends ClientProxy {

    protected CustomClientProxy(String serviceName, String objectName) {
        super(serviceName, objectName);
    }
}


But currently a recent change done in ClientProxy constructor makes this impossible. ClientProxy requires client.getName() which not possible to inject from outside. 
I made a fix and pull requests are on review phase;



Mehmet Dogan
Chief Architect
 
Mahir İz Cad. No:35, Altunizade, İstanbul 
meh...@hazelcast.com 
@mmdogan



--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/840d0354-a569-4109-8d04-0b9e60e002c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages