Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connections for every message instead of every client #10

Open
craig8 opened this issue May 18, 2015 · 1 comment
Open

connections for every message instead of every client #10

craig8 opened this issue May 18, 2015 · 1 comment

Comments

@craig8
Copy link
Contributor

craig8 commented May 18, 2015

This is is an issue.

@craig8
Copy link
Contributor Author

craig8 commented May 18, 2015

The framework seems to handle this already. Looking at the create method from the ClientFactory service this will only create a new client if a client instances isn't available. Therefore multiple calls to create will not create new clients but reuse the ones already connected based upon protocol.

@Override
public synchronized Client create(PROTOCOL protocol) {
    GossClient client = null;
    for(GossClient c: clientInstances){

        if(!c.isUsed() && c.getProtocol().equals(protocol)){
            client = c;
            client.setUsed(true);
            break;
        }
    }

    if(client == null){
        if (sslEnabled){
            client = new GossClient()
                        .setProtocol(PROTOCOL.SSL)
                        .setUri((String)properties.get(ClientFactory.DEFAULT_BROKER_URI))
                        .setClientTrustStorePassword((String)properties.get(GossCoreContants.PROP_SSL_CLIENT_TRUSTSTORE_PASSWORD))
                        .setClientTrustStore((String)properties.get(GossCoreContants.PROP_SSL_CLIENT_TRUSTSTORE));                          
        }
        else{
            client = new GossClient()
                            .setProtocol(protocol)
                            .setUri((String)properties.get(GossCoreContants.PROP_OPENWIRE_URI));
        }
        clientInstances.add(client);
    }

    return client;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant