ModuleClient Class

Definition

Public API for communicating from Edge Modules. A ModuleClient can be used to send messages from an Edge module to an EdgeHub or an IotHub. It can also send twin updates and listen for method calls from an EdgeHub or IotHub as well

public class ModuleClient extends InternalClient
Inheritance
java.lang.Object
ModuleClient

Inherited Members

Constructors

ModuleClient(String connectionString, IotHubClientProtocol protocol)

Constructor for a ModuleClient instance. or

HostName=xxxx;DeviceId=xxxx;SharedAccessKey= xxxx;moduleId=xxxx;HostNameGateway=xxxx

ModuleClient(String connectionString, IotHubClientProtocol protocol, String publicKeyCertificate, boolean isCertificatePath, String privateKey, boolean isPrivateKeyPath)

Create a module client instance that uses x509 authentication.

Note! Communication from a module to another EdgeHub using x509 authentication is not currently supported and the service will always return "UNAUTHORIZED"

Communication from a module directly to the IotHub does support x509 authentication, though.

or

HostName=xxxx;DeviceId=xxxx;SharedAccessKey= xxxx;moduleId=xxxx;HostNameGateway=xxxx

Methods

createFromEnvironment()

Create a module client instance from your environment variables

createFromEnvironment(IotHubClientProtocol protocol)

Create a module client instance from your environment variables

getTwin()

Retrieves the twin's latest desired properties

invokeMethod(String deviceId, MethodRequest methodRequest)

Invoke a method on a device

invokeMethod(String deviceId, String moduleId, MethodRequest methodRequest)

Invoke a method on a module

sendEventAsync(Message message, IotHubEventCallback callback, Object callbackContext)
sendEventAsync(Message message, IotHubEventCallback callback, Object callbackContext, String outputName)

Sends a message to a particular outputName asynchronously

setMessageCallback(MessageCallback callback, Object context)

Sets the message callback.

setMessageCallback(String inputName, MessageCallback callback, Object context)

Sets the message callback to be fired when a telemetry message arrives on the specified input channel. All other messages will trigger the default message callback in setMessageCallback(MessageCallback callback, Object context). Any message that triggers this callback will not also trigger the default callback.

startTwin(IotHubEventCallback deviceTwinStatusCallback, Object deviceTwinStatusCallbackContext, PropertyCallBack genericPropertyCallBack, Object genericPropertyCallBackContext)

Starts the device twin.

startTwin(IotHubEventCallback deviceTwinStatusCallback, Object deviceTwinStatusCallbackContext, TwinPropertyCallBack genericPropertyCallBack, Object genericPropertyCallBackContext)

Starts the device twin.

subscribeToMethod(DeviceMethodCallback methodCallback, Object methodCallbackContext, IotHubEventCallback methodStatusCallback, Object methodStatusCallbackContext)

Subscribes to method invocations on this module. This does not include method invocations on the device the module belongs to

Applies to