ayache khettar created CAMEL-8537:
-------------------------------------

             Summary: CamelHazelcast component should create its own HZ 
instance only if it's not provided
                 Key: CAMEL-8537
                 URL: https://issues.apache.org/jira/browse/CAMEL-8537
             Project: Camel
          Issue Type: Improvement
          Components: camel-hazelcast
    Affects Versions: 2.15.0
            Reporter: ayache khettar


Hi

Currently Hazelcast component creates its own HZ instance regardless if a 
reference to a HZ instance is provided or not. So in the case of a reference of 
HZ instance is provided, the one created by the component does not get shutdown 
- see below code snippet, doesn't get shutdown. So one end up with multipole 
instances.

I believe the component should not create its own instance at the doStart() 
method. It should first check if a reference to HZ instance is provided, if yes 
then use it and if not create its own. 

I have made the changes to reflect the correct behaviour described above. The 
changes will make sure only one instance of HZ is created. Also, added the 
ability to reference HZ instance by its name.

{panel:title=What 
remains?|borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1|bgColor=#FFFFCE}

* Update the wiki to show how to reference HZ by its name
* Update the wiki to show the newly introduced parameter (hazelcastInstanceName)
* Update the wiki to ideally show an example of how to publish HZ instance as 
an OSGI service for reuse by multiple bundles.
{panel}

{panel:title=Changes 
made|borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1|bgColor=#FFFFCE}

* No longer the component creates its own HZ instance in doStart() method.
* When the component is initialised, only one instance is either been created 
or use the referenced on in the endpoint.
* Ability to reference HZ instance by its name. This will serve the use case 
whereby the hazelcast cluster is running remotely or not part of the camel 
context.
{panel}


{code:title=HazelcastComponent.java|borderStyle=solid}
 @Override
    public void doStart() throws Exception {
        super.doStart();
        if (hazelcastInstance == null) {
            createOwnInstance = true;
            hazelcastInstance = createOwnInstance();
        }
    }
{code}






I have created a pull request for this, details can be seen here: 
https://github.com/apache/camel/pull/443





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to