use of com.creditease.uav.messaging.api.MessageConsumer in project uavstack by uavorg.
the class StandardMessagingBuilder method buildConsumer.
/**
* buildConsumer
*
* @param groupName
* @param msgType
* @param queueType
* @return
*/
public MessageConsumer buildConsumer(String groupName, String msgType, MQFactory.QueueType queueType) {
String ConsumeThreadMax = ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".consumethreadmax");
String ConsumeStopInterval = ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".consumestopinterval");
boolean check = DataConvertHelper.toBoolean(ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".enable"), false);
if (check == false) {
return null;
}
String[] bizIDs = new String[1];
bizIDs[0] = msgType;
MessageConsumer consumer = MessagingFactory.createMessageConsumer(groupName, bizIDs, ConsumeThreadMax == null ? 10 : Integer.parseInt(ConsumeThreadMax), ConsumeStopInterval == null ? 0 : Long.parseLong(ConsumeStopInterval), queueType);
return consumer;
}
use of com.creditease.uav.messaging.api.MessageConsumer in project uavstack by uavorg.
the class GatherDataManager method start.
@Override
public void start() {
StandardMessagingBuilder builder = new StandardMessagingBuilder("GatherDataManagerMessageBuilder", feature);
try {
builder.init();
} catch (IOException e) {
log.err(this, "Read msgtype2topic.properties FAILs, GatherDataManager can not START", e);
return;
}
String[] topics = getConfigManager().getFeatureConfiguration(feature, "topics").split(",");
List<MessageHandler> handlers = new ArrayList<>();
for (String topic : topics) {
handlers.add(new DefaultGatherDataHandler(topic));
}
MessagingContext.putConsumerHandlers(handlers);
// init consumers
consumers = new ArrayList<>();
for (String topic : topics) {
MessageConsumer consumer = builder.buildConsumer(topic);
if (consumer == null) {
continue;
}
consumers.add(consumer);
}
// start all consumers
for (MessageConsumer consumer : consumers) {
consumer.start();
log.info(this, "GatherData Consumer [" + consumer.getName() + "] start");
}
log.info(this, "GatherDataManager start");
}
use of com.creditease.uav.messaging.api.MessageConsumer in project uavstack by uavorg.
the class GatherDataManager method stop.
@Override
public void stop() {
for (MessageConsumer consumer : consumers) {
consumer.shutdown();
log.info(this, "GatherData Consumer [" + consumer.getName() + "] shutdown");
}
log.info(this, "GatherDataManager stop");
}
use of com.creditease.uav.messaging.api.MessageConsumer in project uavstack by uavorg.
the class TestRMQMessageConsumer method main.
public static void main(String[] args) {
Map<String, String> msgType2topicMap = new HashMap<String, String>();
msgType2topicMap.put("test", "JQ_Sub2");
String[] consumerHandlerClasses = "test.messaging.TestMessageHandler".split(",");
MessagingContext.init("127.0.0.1:9876", msgType2topicMap, consumerHandlerClasses, 30L, 262000L);
SystemLogger.init("INFO", true, 5);
String[] bizIDs = new String[1];
bizIDs[0] = "test";
String[] handlerNames = new String[1];
handlerNames[0] = "test";
MessageConsumer consumer = MessagingFactory.createMessageConsumer("name", bizIDs, 10, 0);
consumer.start();
}
use of com.creditease.uav.messaging.api.MessageConsumer in project uavstack by uavorg.
the class StandardMessagingBuilder method buildConsumer.
/**
* build comsumer by msgtype
*/
public MessageConsumer buildConsumer(String msgType, MQFactory.QueueType queueType) {
String ConsumeThreadMax = ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".consumethreadmax");
String ConsumeStopInterval = ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".consumestopinterval");
boolean check = DataConvertHelper.toBoolean(ConfigurationManager.getInstance().getFeatureConfiguration(feature, msgType + ".enable"), true);
if (check == false) {
return null;
}
String[] bizIDs = new String[1];
bizIDs[0] = msgType;
MessageConsumer consumer = MessagingFactory.createMessageConsumer(msgType, bizIDs, ConsumeThreadMax == null ? 10 : Integer.parseInt(ConsumeThreadMax), ConsumeStopInterval == null ? 0 : Long.parseLong(ConsumeStopInterval), queueType);
return consumer;
}
Aggregations