I am developing a frontend iOS application that needs to consume events from a Solace queue using MQTTv5. Does MQTT v5 support consuming all persistent messages from a queue?
Here’s a bit of the code I’m using. Could you provide any corrections or clarifications?
NOTE: I am using over websocket with port 8443
Hi there, I’m Solly AI, I generate responses to your questions using the power of the Solace Agent Mesh:
Please remember that AI technology can make mistakes so ensure that you read our Disclaimer.
AI Generated responses are a work in progress, your help in evaluating my response would be awesome! If my response makes sense, please mark it as a solution or give a . If my response doesn’t make sense for your topic, please react to it with a .
Let me analyze the information about MQTT queue-based message consumption in iOS.
The documentation indicates that while MQTT doesn’t natively support direct queue consumption, Solace implements queue functionality under the hood for MQTT connections with specific configurations:
For persistent message consumption with MQTT v5:
Set Clean Session to false
Use the same client ID consistently
Use QoS1 for subscriptions
Configure session expiry interval in connect properties
For WebSocket connections:
Port 8443 is used for MQTT over WebSocket Secure (WSS)
Port 8883 is used for MQTT over SSL/TLS
The code you shared needs some adjustments to enable persistent message consumption:
Set cleanSession to false
Configure a non-zero sessionExpiryInterval
Use QoS1 for subscriptions
MQTT v5 is recommended over MQTT 3.1.1 for better features and interoperability with Solace event brokers.
Hi @Srikanth_bethi,
As @amackenzie said in the other thread the MQTT5 specification does not include queues and b/c of that the MQTT libraries won’t allow you to explicitly connect to a queue. But Solace’s implementation of QoS uses queues under the covers.
Hi @marc and @amackenzie ,
The links provided do not offer sufficient information to help me achieve my goal of developing the iOS application. Could you please address the queries below and provide your valuable insights and suggestions?
Task :
I am developing a frontend iOS application that will interact with a Solace messaging system to both publish events to a specified topic and consume events from a queue.
Questions:
Does Solace support message consumption from a queue?
Can the same functionality be achieved using an MQTT library? If MQTT is not suitable, could you suggest alternative approaches for iOS mobile application development to achieve this functionality?
Hi @amackenzie ,
Thank you so much for quick response.
I’m working on iOS front-end application development. I have successfully published messages with QoS1 and can view the “Try Me” dashboard with messages stored in persistent mode. I sent 20 messages, but now I’m having trouble consuming all the persistent 20 messages via topics. I am unable to do so. Could you please provide suggestions, sample code, or any relevant iOS documentation? I would really appreciate your help.
Hi @amackenzie@marc
We are seeking guidance on how the functionality works in the ‘Try Me’ section, and would like to implement the same functionality for the iOS front-end. Could you please provide the steps or code to achieve this on the iOS side?
Hi @Srikanth_bethi,
The Try-Me tool inside of PS+ Manager uses our javascript SMF API w/ the broker’s web messaging port. Another example of this would be the CodePens in section 3 on this page: https://solace.com/products/event-broker/software/getting-started. If you click on the “Edit in CodePen” button at the top right of each of them you’ll be able to see the code. Hope that helps!
Hi @marc
Could you please provide guidance on how to retrieve all persistent messages from a topic/queue using the MQTT framework in an iOS front-end application?
I’m working on iOS front-end application development. I have successfully published messages with QoS1 with messages stored in persistent mode. I sent 20 messages, but now I’m having trouble consuming all the persistent 20 messages via topics. I am unable to do so. Could you please provide suggestions, sample code, or any relevant iOS documentation? I would really appreciate your help.
Providing iOS code with you, Could you please verify and provide corrections for my requirement fulfill. code:
let clientID = “CocoaMQTT-(“sample”)-” + String(ProcessInfo().processIdentifier)
let websocket = CocoaMQTTWebSocket(uri: “/mqtt”)
websocket.enableSSL = true
mqtt = CocoaMQTT(clientID: mqttClientID, host: mqttHost, port: mqttPort, socket: websocket)
mqtt!.username = “solace-cloud-client”
mqtt!.password = “oc1h2uejbmurk5r7fjv296v07a”
mqtt!.autoReconnect = true
mqtt!.keepAlive = 60
mqtt!.enableSSL = true
mqtt!.delegate = self
mqtt!.cleanSession = false
mqtt!.logLevel = .debug
connection : let connect = mqtt!.connect() To publish message : mqtt!.publish(topic, withString: message, qos: .qos1, retained: false) To subscribe messages : mqtt.subscribe(topic, qos: .qos1)