You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Java language to develop the solution, and I am using the latest SDK: 2.1.7 of iot-service-client maven artifact. In the previous SDK(1.34.2), there was a method to set the expiration of the message: setExpiryTimeUtc(long milliseconds), but in this new sdk, this method is removed.
I have tried setting the Properties of the Message but still, the message is not getting expired by the desired time as configured. Please refer to the code below. The message should expire after 1 minute from now, but when I open the device client, the message is still there to recieve.
Java
//Added Properties to set the expiration time of the message
Map<String, String > properties = new HashMap<String, String>();
// Set the absolute expiry time (e.g., 1 hour from now)
Instant expiryTime = Instant.now().plus(1, ChronoUnit.MINUTES);
properties.put("absolute-expiry-time", String.valueOf(expiryTime.toEpochMilli()));
messageToSend.setProperties(properties);
messageToSend.setDeliveryAcknowledgement(DeliveryAcknowledgement.Full);
The text was updated successfully, but these errors were encountered:
The service client SDK you are referencing is maintained in a separate repo by different maintainers these days. It looks like you already filed the issue over there, but I can poke the maintainers of that repo to take another look into this for you.
I am well aware of setting the message expiration time from the portal by configuring the Default TTL under Cloud to device Messaging of Iot Hub.
From the documentation(https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d), we can override this property by setting the ExpiryTimeUtc property in the service(By using iot service SDK)
I am using Java language to develop the solution, and I am using the latest SDK: 2.1.7 of iot-service-client maven artifact. In the previous SDK(1.34.2), there was a method to set the expiration of the message: setExpiryTimeUtc(long milliseconds), but in this new sdk, this method is removed.
I have tried setting the Properties of the Message but still, the message is not getting expired by the desired time as configured. Please refer to the code below. The message should expire after 1 minute from now, but when I open the device client, the message is still there to recieve.
Java
//Added Properties to set the expiration time of the message
Map<String, String > properties = new HashMap<String, String>();
// Set the absolute expiry time (e.g., 1 hour from now)
Instant expiryTime = Instant.now().plus(1, ChronoUnit.MINUTES);
properties.put("absolute-expiry-time", String.valueOf(expiryTime.toEpochMilli()));
messageToSend.setProperties(properties);
messageToSend.setDeliveryAcknowledgement(DeliveryAcknowledgement.Full);
The text was updated successfully, but these errors were encountered: