Use-case of the ServiceClient? - azure-iot-hub

Is the use-case of the ServiceClient to send messages to devices?
ServiceClient supports only amqp messages. Documentation for Azure Devices namespace says "Transport types supported by ServiceClient - Amqp and Amqp over WebSocket only". In code the TransportType exposes only Amqp. Would it be changed in the future?
If the ServiceClient is been used for C2D messages, why in this answer, is written that "For ServiceClient, you need Azure IoT Hub connection string, not device connection string"?
What is the performance's impact and resources' utilization, if we hold a reference of the created ServiceClient object (or the Registry Manager)?
and what is the impact in case
when we open-close the connection?
when we leave open the conection?

Is the use-case of the ServiceClient to send messages to devices?
Yes. You need use ServiceClient to send C2D messages.
ServiceClient supports only amqp messages. Documentation for Azure
Devices namespace says "Transport types supported by ServiceClient -
Amqp and Amqp over WebSocket only". In code the TransportType exposes
only Amqp. Would it be changed in the future?
For future plans, you can reference this guide ask a question.
If the ServiceClient is been used for C2D messages, why in this
answer, is written that "For ServiceClient, you need Azure IoT Hub
connection string, not device connection string"?
Device connection string: Connection string based on primary key used in API calls which allows device to communicate with Iot Hub. It allows you to receive C2D messages, not send C2D messages. IoT Hub exposes its functionality to various actors, like per-device and service.
What is the performance's impact and resources' utilization, if we
hold a reference of the created ServiceClient object (or the Registry
Manager)?
You can check IoT Hub throttling and you and IoT Hub quotas and throttling for more detail.

Related

Azure IoT on Edge - IoTSDK - Read batch of messages from ModuleClient

I'm tryng to develop an high-frequency message dispatching application and i'm observing for the behavior of the SDK about message reading from the ModuleClient connected to the edgeHub by using "MQTT on TCP Only" transport settings.
Seems that there is no way to read multiple messages at time (batch) from the edgeHub (I think is something related to the underlying protocol).
So the result is that one must sequentially read a message, process it and give the ack to the hub.
Does exist a way to process multiple message at time without waiting for the processing of the previous?
Is this "limitation" tied to the underlyng protocol?
I'm using Microsoft.Azure.Devices.Client 1.37.2 on a .NET Core 3.1 application deployed on Azure Kubernetes (AKS) by using Azure IoT Edge on Kubernetes workload.
You are correct, you cannot use batch in MQTT protocol. This is a limitation tied to IoTHub when using MQTT Protocol.
IoT Hub only supports batch send over AMQP and HTTPS at the moment.
The MQTT implementation loops over the batch and sends each message
individually.
Ref: https://github.com/Azure/azure-iot-sdk-csharp
Suggest that you add a new feature request, if need IoTHub to support batch when connecting using MQTT: https://feedback.azure.com/forums/321918-azure-iot-hub-dps-sdks

RabbitMQ and IoT device: keep queue open?

We're using RabbitMQ in a new project. We'll have IoT devices communicating with queues.
For the devices to send info to the cloud we don't see any issues, however sometimes we need to deliver messages from our backend to the IoT devices. For this we let the devices open an exclusive queue. This works perfectly, as long as the devices are online. When they aren't, the queue is closed and no messages can be send to it anymore.
Is there a way to keep the queue open, so messages are kept until the IoT device comes back online?
Vice-versa: Is there some way to have guaranteed delivery starting at the IoT device. For example: energy measurements every 15 minutes. If the connection drops, messages should be stored on disk (to prevent message loss in case of power cut). They are sent later on when the connection comes back online. Does a service or client library exist that implements this or do we need to develop this ourselves?
Is there a way to keep the queue open, so messages are kept until the
IoT device comes back online?
Use a regular queue, and make sure it's durable if you'd like it to survive RabbitMQ restarts.
Is there some way to have guaranteed delivery starting at the IoT
device.
That depends on the library you are using, but you don't tell us what library nor what protocol you're using (AMQP vs MQTT, for instance).
Some libraries offer automatic reconnect and re-creation of topology (queues, exchanges, etc) but I'm not aware of any that offer local storage of messages until the broker is available again. You'll have to code that yourself.
Please carefully read the documentation with regard to publisher confirmations and consumer acknowledgements, as those are both necessary for reliable messaging link.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
Our Cloud has several exchanges and credentials called CredentialsBucket assigned to a set of IoT devices. When an IoT device register, we provide them this credentials that includes a durable queue and exchange. When the IoT device push messages, it goes to Cloud through the exchange where we do additional security check using HMAC.
When Cloud send a message, it send it directly to his queue (no persistent messages in our case) and the IoT device do the same kind of security check.

Messaging systems reliability

‌I understand that every messaging platform (rabbitmq, activemq) provides some mechanism that guarantees message delivery between the server (rabbitmq) and the consumers, so if a consumer is down, the message will still be in a queue and redelivered. But what happens in case the messaging platform is down and the client (producer of the message) could not deliver the message to the platform (Rabbitmq)? In that case, a retry method to redeliver the message is needed, but I'm not sure if I have to implement it myself, or clients libraries have this option , is it declared as a parameter in the connection/channel creation? is it platform specific? Also, protocols like AMQP specifies this? I heard also from Spring Retry as a option.
A spring-retry RetryTemplate can be wired directly into Spring AMQP's RabbitTemplate.
Kafka has retry capability built into the Producer (see the retries property).
For JMS, you can wrap the JmsTemplate into a RetryTemplate.execute() method.
The retry policy, back-off etc is all configurable.

UDP packets to Azure Event Hubs

Does Azure Event Hub consume UDP packets? I want to utilize Azure Event Hubs but it seems limited to only TCP.
As far as I know, to send the data to Event Hubs, developers must publish the events via the AMQP or the HTTPS. UDP is a connectionless protocol, it seems not support in Azure Event Hubs.
For detailed information about Event Hubs protocol, please refer to this article: AMQP 1.0 in Azure Service Bus and Event Hubs protocol guide.

MQTT in Producer /consumer context

we are using ActiveMQ for message Queuing with openwire transport.In this context there will be one producer and one consumer with a message listener registered. We heard about MQTT protocol and its support in activeMQ. But i saw examples only for Publisher/subscriber semantics , where subscriber need to call receive method explicitly to get the published message. Can I use mqtt with Producer/Consumer envirnment. Please give a sample..
The MQTT protocol is based a publish / subscribe based model, it has no queuing semantics built into the protocol. If you need Queue's then you need to stick to openwire clients or use a STOMP based client which supports both Topics and Queues.