Reputation: 1575
I am trying to send a message to ActiveMQ from a sender written in C# and then trying to receive the message on an android device running ActiveMQ Client.
I was not able to do this. Any help will be appreciated.
I am using the paho eclipse client.
Here is my code:
//Connection with the server
private void connect() {
MqttConnectOptions connectOptions = new MqttConnectOptions();
connectOptions.setAutomaticReconnect(true);
client = new MqttAndroidClient(this, serverURI, clientId);
try {
client.connect(connectOptions, new IMqttActionListener() {
@Override
public void onSuccess(IMqttToken asyncActionToken) {
publishBtn.setEnabled(true);
subscribe();
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable e) {
e.printStackTrace();
}
});
} catch (MqttException e) {
e.printStackTrace();
}
}
Upvotes: 1
Views: 213
Reputation: 18376
Yes, you can do this as long as you have configured the broker to add an MQTT Transport endpoint. You will also need to ensure your device can reach the broker which could be behind a firewall or other security measures so configuration here is key. The ActiveMQ 5.x broker configuration for MQTT is documented here.
Upvotes: 1