public class MQProducer extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected com.aliyun.mq.http.common.auth.ServiceCredentials |
credentials
object content user auth info
|
protected URI |
endpoint
user mq http endpoint, ie: http://uid.mqrest.region.aliyuncs.com/
|
protected String |
instanceId
instance id
|
protected com.aliyun.mq.http.common.http.ServiceClient |
serviceClient |
protected String |
topicName |
protected String |
topicURL
topic url, ie: http://uid.mqrest.region.aliyuncs.com/topics/topicName
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
MQProducer(String instanceId,
String topicName,
com.aliyun.mq.http.common.http.ServiceClient client,
com.aliyun.mq.http.common.auth.ServiceCredentials credentials,
URI endpoint) |
| 限定符和类型 | 方法和说明 |
|---|---|
AsyncResult<TopicMessage> |
asyncPublishMessage(TopicMessage msg,
AsyncCallback<TopicMessage> callback)
async publish message to topic.
|
protected void |
checkMessage(TopicMessage msg) |
String |
getInstanceId() |
String |
getTopicName() |
TopicMessage |
publishMessage(TopicMessage msg)
publish message to topic.
|
String |
toString() |
protected com.aliyun.mq.http.common.http.ServiceClient serviceClient
protected String topicURL
protected String topicName
protected com.aliyun.mq.http.common.auth.ServiceCredentials credentials
protected URI endpoint
protected String instanceId
protected MQProducer(String instanceId, String topicName, com.aliyun.mq.http.common.http.ServiceClient client, com.aliyun.mq.http.common.auth.ServiceCredentials credentials, URI endpoint)
instanceId, - instance idtopicName, - topic nameclient, - ServiceClient objectcredentials, - ServiceCredentials objectendpoint, - user mq http endpoint, ie: http://uid.mqrest.region.aliyuncs.com/public String getTopicName()
public String getInstanceId()
protected void checkMessage(TopicMessage msg) throws ClientException
ClientExceptionpublic TopicMessage publishMessage(TopicMessage msg) throws ServiceException, ClientException
- Timing message : TopicMessage.setStartDeliverTime(long)
- Ordered message : TopicMessage.setShardingKey(String)
msg - messageServiceException - Exception from serverClientException - Exception from clientpublic AsyncResult<TopicMessage> asyncPublishMessage(TopicMessage msg, AsyncCallback<TopicMessage> callback)
- Timing message : TopicMessage.setStartDeliverTime(long)
- Ordered message : TopicMessage.setShardingKey(String), it's recommended to sync publish order message.
msg - messagecallback, - user callback objectCopyright © 2021. All Rights Reserved.