Class SingleInstanceAmqpConnectionFactory
java.lang.Object
com.sportradar.unifiedodds.sdk.internal.impl.rabbitconnection.SingleInstanceAmqpConnectionFactory
- All Implemented Interfaces:
AmqpConnectionFactory
A
AmqpConnectionFactory implementation which creates only one connection instance. All
subsequent calls to newConnection() method return instance created by the first call.-
Constructor Summary
ConstructorsConstructorDescriptionSingleInstanceAmqpConnectionFactory(ConfiguredConnectionFactory configuredConnectionFactory, SdkInternalConfiguration config, SdkConnectionStatusListener connectionStatusListener, WhoAmIReader whoAmIReader, FirewallChecker firewallChecker, TimeUtils timeUtils, SslProtocolsProvider sslProtocolsProvider) Initializes a new instance of theSingleInstanceAmqpConnectionFactoryclass -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the connection can or should be openedvoidclose(boolean feedStopped) Close the AMQP connectioncom.rabbitmq.client.ConnectionReturns aConnectioninstance representing connection to the AMQP brokerlongGet the timestamp when the connection startedbooleanCheck if the connection is currently alive
-
Constructor Details
-
SingleInstanceAmqpConnectionFactory
@Inject public SingleInstanceAmqpConnectionFactory(ConfiguredConnectionFactory configuredConnectionFactory, SdkInternalConfiguration config, SdkConnectionStatusListener connectionStatusListener, WhoAmIReader whoAmIReader, FirewallChecker firewallChecker, TimeUtils timeUtils, SslProtocolsProvider sslProtocolsProvider) Initializes a new instance of theSingleInstanceAmqpConnectionFactoryclass- Parameters:
configuredConnectionFactory- AConfiguredConnectionFactoryinstance used to create theConnectioninstanceconfig- ASdkInternalConfigurationinstance representing odds feed configurationconnectionStatusListener- ASdkConnectionStatusListenerused to notify the outside world when the connection is closed
-
-
Method Details
-
getConnection
public com.rabbitmq.client.Connection getConnection()Returns aConnectioninstance representing connection to the AMQP broker- Specified by:
getConnectionin interfaceAmqpConnectionFactory- Returns:
- a
Connectioninstance representing connection to the AMQP broker
-
close
Close the AMQP connection- Specified by:
closein interfaceAmqpConnectionFactory- Parameters:
feedStopped- indication if feed was stopped- Throws:
IOException- if the connection couldn't be terminated
-
isConnectionHealthy
public boolean isConnectionHealthy()Description copied from interface:AmqpConnectionFactoryCheck if the connection is currently alive- Specified by:
isConnectionHealthyin interfaceAmqpConnectionFactory- Returns:
- the status of the connection
-
getConnectionStarted
public long getConnectionStarted()Get the timestamp when the connection started- Specified by:
getConnectionStartedin interfaceAmqpConnectionFactory- Returns:
- the timestamp when the connection started
-
canConnectionOpen
public boolean canConnectionOpen()Check if the connection can or should be opened- Specified by:
canConnectionOpenin interfaceAmqpConnectionFactory- Returns:
- value indicating if the connection can or should be opened
-