add parallelism on consumers
@@ -68,6 +68,9 @@ public abstract class AbstractVnfmSpringAmqp extends AbstractVnfm
@Value("${spring.rabbitmq.virtualHost:/}")
private String virtualHost;
+ @Value("${vnfm.consumers.num:5}")
+ private int consumers;
+
@Autowired private Gson gson;
@Autowired private ConfigurableApplicationContext context;
@Autowired private Registration registration;
@@ -78,11 +81,7 @@ public abstract class AbstractVnfmSpringAmqp extends AbstractVnfm
super.setup();
}
- @PostConstruct
- private void listenOnQueues() {
- Thread thread =
- new Thread(
- new Runnable() {
+ private class ConsumerRunnable implements Runnable {
@Override
public void run() {
ConnectionFactory connectionFactory = new ConnectionFactory();
@@ -156,10 +155,19 @@ public abstract class AbstractVnfmSpringAmqp extends AbstractVnfm
}
}
}
- });
+ }
+
+ @PostConstruct
+ private void listenOnQueues() {
+
+ for (int i = 0; i < consumers; i++) {
+ Runnable listenerRunnable = new ConsumerRunnable();
+ Thread thread = new Thread(listenerRunnable);
thread.setDaemon(true);
thread.start();
}
+ log.info("Started " + consumers + " consumers");
+ }
@Override
protected void unregister() {
