0

Let's say I have class1 which is implementing Identified Serializable and created jar and put this library in Hazelcast/bin/user-lib. If I want to add new Identified Serializable class "class2" in that jar file then again I need to put it in the Hazelcast/bin/user-lib and need to restart all the member of the cluster then only I my client application can work properly with serialization/deserialization.

Is there any alternative to handle this scenario without cluster node restart every time I add new class?

1 Answers1

0

You can use User Code Deployment feature, see Deploying User Code from Clients section of the documentation, but in short:

  • You need to enable user code deployment on all members:

      <hazelcast>
          <user-code-deployment enabled="true">
          ...
          </user-code-deployment>
      </hazelcast>
    
  • and on the client:

      <hazelcast-client>
          <user-code-deployment enabled="true">
              <jarPaths>
                  <jarPath>/User/example/example.jar</jarPath>
              </jarPaths>
              <classNames>
                  <!-- for classes available in client's class path -->
                  <className>example.ClassName</className>
                  <className>example.ClassName2</className>
              </classNames>
          </user-code-deployment>
      </hazelcast-client>
    

Note that user code deployment has one major drawback - once you upload a class to the cluster it stays there forever and can't be updated unless you turn off class caching, which is suitable for e.g. tasks you submit to executor service, but not for domain objects.

František Hartman
  • 14,436
  • 2
  • 40
  • 60