

Consumer consumer = new Consumer();// VPC address: http://{region}.mqadapter.cmq.tencentyun.com. CVM instances in a VPC can be accessed over the private network// Public network address: https://cmq-{region}.public.tencenttdmq.comconsumer.setNameServerAddress("http://****.com");// Set `SecretId`, which is required and can be obtained from the consoleconsumer.setSecretId("****");// Set `SecretKey`, which is required and can be obtained from the consoleconsumer.setSecretKey("****");// Set the signature algorithm, which is optional and is SHA1 by defaultconsumer.setSignMethod(ClientConfig.SIGN_METHOD_SHA256);// Set the maximum number of messages that can be pulled in batches, which ranges from 1 to 16consumer.setBatchPullNumber(16);// Set the wait timeout period, which is 10s by default. You can pass in the specific wait time in methods such as `consumer.receiveMsg`consumer.setPollingWaitSeconds(6);// Set the request timeout period, which is 3,000 ms by default// If you set the wait timeout period to 6s and request timeout period to 5,000 ms, the final timeout period will be (6 * 1000 + 5000) msconsumer.setRequestTimeoutMS(5000);// Name of the queue from which messages are pulledfinal String queue = "****";
NameServer value of the original producer to the access address of the TDMQ for CMQ queue, which can be copied in Queue Service > API Request Address in the TDMQ for CMQ console.Feedback