RoboMQ is RabbitMQ client wrapper-library for android base on java library
- initiation
//activity or service implement MQCallback
MQFactory mqFactory = new MQFactory(MQConfig.hostName,
MQConfig.virtualHostname,
MQConfig.username,
MQConfig.password,
MQConfig.exchange,
MQConfig.rotuingkey,
MQConfig.port);
// callback injected by factory instances for create consumer and produser instance
MQConsumer mqConsumer = this.mqFactory.createConsumer(this);
MQProducer mqProducer = this.mqFactory.createProducer(this);
- set property
mqConsumer.setQueueName("newQueueName");
mqConsumer.setRoutingkey("newRoutingKey");
mqConsumer.setExchange("newExchange");
- start and stop consumer
mqConsumer.setMessageListner(new MQConsumer.MQConsumerListener() {
@Override
public void onMessageReceived(QueueingConsumer.Delivery delivery) {
//use delivery message
}
});
mqConsumer.subsribe();
mqConsumer.stop();
- start and stop produser
mqProducer.publish(message, null);
for long running operation, preferably using a service