public class MQConsumer extends Object
| 限定符 | 构造器和说明 |
|---|---|
protected |
MQConsumer(String instanceId,
String topicName,
String consumer,
String messageTag,
com.aliyun.mq.http.common.http.ServiceClient client,
com.aliyun.mq.http.common.auth.ServiceCredentials credentials,
URI endpoint) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
ackMessage(List<String> receiptHandles)
Tell server the messages are consumed success.
|
AsyncResult<Void> |
asyncAckMessage(List<String> receiptHandles,
AsyncCallback<Void> callback)
Async tell server the messages are consumed success.
|
AsyncResult<List<Message>> |
asyncConsumeMessage(int num,
int pollingSecond,
AsyncCallback<List<Message>> callback)
async consume message from topic.
|
List<Message> |
consumeMessage(int num,
int pollingSecond)
sync consume message from topic.
|
List<Message> |
consumeMessageOrderly(int num,
int pollingSecond)
sync consume message from topic orderly.
|
String |
getConsumer()
the consumer group name of mq
|
String |
getInstanceId()
instance id
|
String |
getMessageTag()
filter message tag, could be null.
|
String |
getTopicName()
the topic name
|
String |
toString() |
protected MQConsumer(String instanceId, String topicName, String consumer, String messageTag, com.aliyun.mq.http.common.http.ServiceClient client, com.aliyun.mq.http.common.auth.ServiceCredentials credentials, URI endpoint)
instanceId, - instance idtopicName, - topic nameconsumer - mq cidmessageTag - message tag for filterclient, - ServiceClient objectcredentials, - ServiceCredentials objectendpoint, - user mq http endpoint, ie: http://uid.mqrest.region.aliyuncs.com/public String getTopicName()
public String getConsumer()
public String getMessageTag()
public String getInstanceId()
public List<Message> consumeMessage(int num, int pollingSecond) throws ServiceException, ClientException
consumeMessage(int, int) are not acked by ackMessage(List), they will be consumable again after 300 seconds;num - the count of messages consumed once
value: 1~16pollingSecond - if greater than 0, means the time(second) the request holden at server if there is no message to consume.
If less or equal 0, means the server will response back if there is no message to consume.
value: 1~30ServiceExceptionClientExceptionpublic List<Message> consumeMessageOrderly(int num, int pollingSecond) throws ServiceException, ClientException
num - the count of messages consumed once
value: 1~16pollingSecond - if greater than 0, means the time(second) the request holden at server if there is no message to consume.
If less or equal 0, means the server will response back if there is no message to consume.
value: 1~30Message.getShardingKey()ServiceExceptionClientExceptionpublic AsyncResult<List<Message>> asyncConsumeMessage(int num, int pollingSecond, AsyncCallback<List<Message>> callback)
consumeMessage(int, int) are not acked by ackMessage(List), they will be consumable again after 300 seconds;num - the count of messages consumed once
value: 1~16pollingSecond - if greater than 0, means the time(second) the request holden at server if there is no message to consume.
If less or equal 0, means the server will response back if there is no message to consume.
value: 1~30callback, - user callback objectpublic void ackMessage(List<String> receiptHandles) throws ServiceException, ClientException
consumeMessage(int, int) are not acked by ackMessage(List), they will be consumable again after 300 seconds;receiptHandles - size should be 1~16, @see Message.receiptHandleServiceException - Exception from serverClientException - Exception from clientpublic AsyncResult<Void> asyncAckMessage(List<String> receiptHandles, AsyncCallback<Void> callback) throws ServiceException, ClientException
consumeMessage(int, int) are not acked by ackMessage(List), they will be consumable again after 300 seconds;receiptHandles - size should be 1~16, @see Message.receiptHandle,callback, - user callback objectServiceException - Exception from serverClientException - Exception from clientCopyright © 2021. All Rights Reserved.