-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented pooled connection factory to AMQ
- Loading branch information
Showing
13 changed files
with
402 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
...-impl/src/main/java/io/subutai/core/environment/metadata/impl/BrokerSettingException.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
.../subutai-hub-share/src/main/java/io/subutai/hub/share/broker/BrokerConnectionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.subutai.hub.share.broker; | ||
|
||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.jms.ConnectionFactory; | ||
|
||
import org.apache.activemq.ActiveMQConnectionFactory; | ||
import org.apache.activemq.jms.pool.PooledConnectionFactory; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
|
||
public class BrokerConnectionFactory | ||
{ | ||
|
||
private final int poolSize; | ||
private Map<BrokerTransport.Type, PooledConnectionFactory> pool = new HashMap<>(); | ||
|
||
|
||
public BrokerConnectionFactory( int poolSize ) | ||
{ | ||
Preconditions.checkArgument( poolSize > 0 ); | ||
Preconditions.checkArgument( poolSize < 5 ); | ||
|
||
this.poolSize = poolSize; | ||
} | ||
|
||
|
||
public ConnectionFactory getConnectionFactory( BrokerTransport.Type type ) | ||
{ | ||
return pool.get( type ); | ||
} | ||
|
||
|
||
public ConnectionFactory getConnectionFactory( BrokerTransport transport ) throws InvalidTransportException | ||
{ | ||
Preconditions.checkNotNull( transport ); | ||
|
||
BrokerTransport.Type type = BrokerTransport.getType( transport.getUri() ); | ||
|
||
PooledConnectionFactory cf = this.pool.get( type ); | ||
|
||
if ( cf != null ) | ||
{ | ||
return cf; | ||
} | ||
ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory( transport.getUri() ); | ||
cf = new PooledConnectionFactory(); | ||
cf.setConnectionFactory( amq ); | ||
cf.setMaxConnections( this.poolSize ); | ||
this.pool.put( type, cf ); | ||
|
||
return cf; | ||
} | ||
} |
Oops, something went wrong.