ons Consumer Startup Report The consumer group[CID-TEST-CONSOLE] has been created before, specify

 

The consumer group[CID-TEST-CONSOLE] has been created before, specify another name please.

 

Launching ONSClient.createConsumer multiple times causes problems with the repeated creation of the same consumer.

It is to use the same consumer id, and then start multiple topics for consumption. Because the consumer object has been created. If it is created again, an error will be reported.

Properties properties = new Properties();

 

 

properties.put(PropertyKeyConst.ConsumerId, consumerId);

 

properties.put(PropertyKeyConst.AccessKey, appKey);

 

properties.put(PropertyKeyConst.SecretKey, appSecret);

 

properties.put(PropertyKeyConst.OnsChannel, ONSChannel.CLOUD);

 

properties.put(PropertyKeyConst.MessageModel,PropertyValueConst.CLUSTERING);

 

Consumer consumer = ONSFactory.createConsumer(properties);

 

consumer.subscribe(topic, "*", new MessageListener() {

 

public Action consume(Message message, ConsumeContext context) {

 

//System.out.println("Receive: " + message);

 

System.out.println("Receive: " + new String(message.getBody()));

 

 

return Action.CommitMessage;

 

}

 

});

consumer.start();

 

Consumer consumer2 = ONSFactory.createConsumer(properties);

consumer2.subscribe("TEST-CONSOLE-COMPANYDETAIL", "*", new MessageListener() {

 

public Action consume(Message message, ConsumeContext context) {

 

//System.out.println("Receive: " + message);

 

System.out.println("companyDetail Receive: " + new String(message.getBody()));

 

 

return Action.CommitMessage;

 

}

 

});

 

consumer2.start();

 

 

=============================

 

Modify it to be normal

Properties properties = new Properties();

 

 

properties.put(PropertyKeyConst.ConsumerId, consumerId);

 

properties.put(PropertyKeyConst.AccessKey, appKey);

 

properties.put(PropertyKeyConst.SecretKey, appSecret);

 

properties.put(PropertyKeyConst.OnsChannel, ONSChannel.CLOUD);

 

properties.put(PropertyKeyConst.MessageModel,PropertyValueConst.CLUSTERING);

 

Consumer consumer = ONSFactory.createConsumer(properties);

 

consumer.subscribe(topic, "*", new MessageListener() {

 

public Action consume(Message message, ConsumeContext context) {

 

//System.out.println("Receive: " + message);

 

System.out.println("Receive: " + new String(message.getBody()));

 

 

return Action.CommitMessage;

 

}

 

});

 

 

consumer.subscribe("TEST-CONSOLE-COMPANYDETAIL", "*", new MessageListener() {

 

public Action consume(Message message, ConsumeContext context) {

 

//System.out.println("Receive: " + message);

 

System.out.println("companyDetail Receive: " + new String(message.getBody()));

 

 

return Action.CommitMessage;

 

}

 

});

 

consumer.start();

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326448380&siteId=291194637