Н
Size: a a a
Н
JS
/
/
I
DP
DP
I
DP
ST
ST
ST
WD
channel.queueDeclare(QUEUE_NAME, true, false, false, null);
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
byte[] body) throws IOException {
String jsonResponse = new String(body, "UTF-8");
int taskId = parseJsonTaskId(jsonResponse);
System.out.println("hostPort = " + numHost);
try {
ExecutorService executor = Executors.newFixedThreadPool(1);
Runnable worker = new ThreadRunner(numHost, taskId);
executor.execute(worker);//calling execute method of ExecutorService
executor.shutdown();
while (!executor.isTerminated()) {
}
} finally {
System.out.println(" [x] Done");
channel.basicAck(envelope.getDeliveryTag(), false);
}
}
};
channel.basicQos(1);
channel.basicConsume(QUEUE_NAME, false, consumer);
PK
D
5
1
4
5