You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/10/18 06:32:02 UTC
[GitHub] [rocketmq] amwyyyy commented on issue #1538: Link to Alibaba Cloud
MQ using version 4.5.1, unable to view message track
amwyyyy commented on issue #1538: Link to Alibaba Cloud MQ using version 4.5.1, unable to view message track
URL: https://github.com/apache/rocketmq/issues/1538#issuecomment-543541094
> @amwyyyy you can add the consumer.setAccessChannel(AccessChannel.CLOUD); before start consumer.
this my test code, it can work, just can not see message track.
```
public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
// producer
DefaultMQProducer producer = new DefaultMQProducer("GID_TEST_SDK", new AclClientRPCHook(new SessionCredentials("xxx", "xxx")));
producer.setAccessChannel(AccessChannel.CLOUD);
producer.setNamesrvAddr("http://xxxx.cn-shanghai-finance-1.mq-internal.aliyuncs.com:8080");
producer.start();
Message msg = new Message("TP_TEST_SDK", "tagA", "hello world!".getBytes());
SendResult sendResult = producer.send(msg);
System.out.println(sendResult);
// consumer
RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials("xxx", "xxx"));
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("GID_TEST_SDK", rpcHook, new AllocateMessageQueueAveragely());
consumer.setAccessChannel(AccessChannel.CLOUD);
consumer.setNamesrvAddr("http://xxx.cn-shanghai-finance-1.mq-internal.aliyuncs.com:8080");
consumer.setMessageModel(MessageModel.CLUSTERING);
consumer.subscribe("TP_TEST_SDK", "*");
consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {
for (MessageExt messageExt : msgs) {
System.out.println(new String(messageExt.getBody()));
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
});
consumer.start();
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services