AmqpsIotHubConnection Class

  • java.lang.Object
    • BaseHandler
      • com.microsoft.azure.sdk.iot.device.transport.amqps.AmqpsIotHubConnection

public class AmqpsIotHubConnection implements IotHubTransportConnection

An AMQPS IotHub connection between a device and an IoTHub or Edgehub. This class is responsible for reacting to connection level and reactor level events. It is also responsible for creating sessions and handlers for those sessions. An instance of this object may be reused after it has been closed. This class is used for both single-plexed and multiplexed connections.

Constructor Summary

Constructor Description
AmqpsIotHubConnection(ClientConfiguration config, String transportUniqueIdentifier)
AmqpsIotHubConnection(String hostName, String transportUniqueIdentifier, boolean isWebsocketConnection, SSLContext sslContext, ProxySettings proxySettings, int keepAliveInterval)

Method Summary

Modifier and Type Method and Description
void close()

Closes the transport connection.

String getConnectionId()

Gives the UUID associated with this connection instance. This string is used in conjunction with the callbacks with connection status updates to ensure that all connection status updates are relevant to this connection object

void onAuthenticationFailed(String deviceId, TransportException transportException)
void onAuthenticationSessionOpened()
void onCBSSessionClosedUnexpectedly(ErrorCondition errorCondition)
void onConnectionBound(Event event)
void onConnectionInit(Event event)
void onConnectionLocalClose(Event event)
void onConnectionLocalOpen(Event event)
void onConnectionRemoteClose(Event event)
void onConnectionRemoteOpen(Event event)
void onDeviceSessionOpened(String deviceId)
void onMessageAcknowledged(Message message, DeliveryState deliveryState, String deviceId)
void onMessageReceived(IotHubTransportMessage message)
void onReactorClosedUnexpectedly()
void onReactorFinal(Event event)
void onReactorInit(Event event)
void onSessionClosedAsExpected(String deviceId)
void onSessionClosedUnexpectedly(ErrorCondition errorCondition, String deviceId)
void onTimerTask(Event event)
void onTransportError(Event event)
void open()

Opens the transport connection object

void registerMultiplexedDevice(ClientConfiguration config)
IotHubStatusCode sendMessage(com.microsoft.azure.sdk.iot.device.Message message)
boolean sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)

Send an acknowledgement to the IotHub for a message that the Transport layer received

void setListener(IotHubListener listener)

Sets a listener into the Transport Connection object. This listener updates the Transport layer of connection status updates, message arrivals, and message acknowledgements

void unregisterMultiplexedDevice(ClientConfiguration config, boolean willReconnect)

Asynchronously unregister a multiplexed device from an active multiplexed connection or synchronously unregister a multiplexed device from a closed multiplexed connection.

Inherited Members

Constructor Details

AmqpsIotHubConnection

public AmqpsIotHubConnection(ClientConfiguration config, String transportUniqueIdentifier)

Parameters:

config
transportUniqueIdentifier

AmqpsIotHubConnection

public AmqpsIotHubConnection(String hostName, String transportUniqueIdentifier, boolean isWebsocketConnection, SSLContext sslContext, ProxySettings proxySettings, int keepAliveInterval)

Parameters:

hostName
transportUniqueIdentifier
isWebsocketConnection
sslContext
proxySettings
keepAliveInterval

Method Details

close

public void close()

Closes the transport connection.

Overrides:

AmqpsIotHubConnection.close()

getConnectionId

public String getConnectionId()

Gives the UUID associated with this connection instance. This string is used in conjunction with the callbacks with connection status updates to ensure that all connection status updates are relevant to this connection object

Overrides:

AmqpsIotHubConnection.getConnectionId()

Returns:

the UUID associated with this connection instance

onAuthenticationFailed

public void onAuthenticationFailed(String deviceId, TransportException transportException)

Parameters:

deviceId
transportException

onAuthenticationSessionOpened

public void onAuthenticationSessionOpened()

onCBSSessionClosedUnexpectedly

public void onCBSSessionClosedUnexpectedly(ErrorCondition errorCondition)

Parameters:

errorCondition

onConnectionBound

public void onConnectionBound(Event event)

Parameters:

event

onConnectionInit

public void onConnectionInit(Event event)

Parameters:

event

onConnectionLocalClose

public void onConnectionLocalClose(Event event)

Parameters:

event

onConnectionLocalOpen

public void onConnectionLocalOpen(Event event)

Parameters:

event

onConnectionRemoteClose

public void onConnectionRemoteClose(Event event)

Parameters:

event

onConnectionRemoteOpen

public void onConnectionRemoteOpen(Event event)

Parameters:

event

onDeviceSessionOpened

public void onDeviceSessionOpened(String deviceId)

Parameters:

deviceId

onMessageAcknowledged

public void onMessageAcknowledged(Message message, DeliveryState deliveryState, String deviceId)

Parameters:

message
deliveryState
deviceId

onMessageReceived

public void onMessageReceived(IotHubTransportMessage message)

Parameters:

message

onReactorClosedUnexpectedly

public void onReactorClosedUnexpectedly()

onReactorFinal

public void onReactorFinal(Event event)

Parameters:

event

onReactorInit

public void onReactorInit(Event event)

Parameters:

event

onSessionClosedAsExpected

public void onSessionClosedAsExpected(String deviceId)

Parameters:

deviceId

onSessionClosedUnexpectedly

public void onSessionClosedUnexpectedly(ErrorCondition errorCondition, String deviceId)

Parameters:

errorCondition
deviceId

onTimerTask

public void onTimerTask(Event event)

Parameters:

event

onTransportError

public void onTransportError(Event event)

Parameters:

event

open

public void open()

Opens the transport connection object

Overrides:

AmqpsIotHubConnection.open()

Throws:

TransportException - If any exceptions are encountered while opening the connection

registerMultiplexedDevice

public void registerMultiplexedDevice(ClientConfiguration config)

Parameters:

config

sendMessage

public IotHubStatusCode sendMessage(com.microsoft.azure.sdk.iot.device.Message message)

Parameters:

message

sendMessageResult

public boolean sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)

Send an acknowledgement to the IotHub for a message that the Transport layer received

Overrides:

AmqpsIotHubConnection.sendMessageResult(IotHubTransportMessage message, IotHubMessageResult result)

Parameters:

message - the message to acknowledge
result - the acknowledgement value to notify the service of

Returns:

true if the acknowledgement was sent successfully, and false otherwise

Throws:

TransportException - if an exception occurred while sending the acknowledgement

setListener

public void setListener(IotHubListener listener)

Sets a listener into the Transport Connection object. This listener updates the Transport layer of connection status updates, message arrivals, and message acknowledgements

Overrides:

AmqpsIotHubConnection.setListener(IotHubListener listener)

Parameters:

listener - the listener for connection status updates, message arrivals, and message acknowledgements

unregisterMultiplexedDevice

public void unregisterMultiplexedDevice(ClientConfiguration config, boolean willReconnect)

Asynchronously unregister a multiplexed device from an active multiplexed connection or synchronously unregister a multiplexed device from a closed multiplexed connection.

Parameters:

config - the config of the device that should be unregistered.
willReconnect - true if the device will be re-registered soon because it is reconnecting.

Applies to