(String[] argv)
| 10 | private static final String QUEUE_NAME = "hello"; |
| 11 | |
| 12 | public static void main(String[] argv) throws Exception { |
| 13 | Environment environment = TutorialSupport.newEnvironment(); |
| 14 | Connection connection = environment.connectionBuilder().uri(TutorialSupport.BROKER_URI).build(); |
| 15 | try (Management management = connection.management()) { |
| 16 | management.queue().name(QUEUE_NAME).quorum().queue().declare(); |
| 17 | } |
| 18 | |
| 19 | System.out.println(" [*] Waiting for messages. To exit press CTRL+C"); |
| 20 | |
| 21 | Consumer consumer = connection.consumerBuilder() |
| 22 | .queue(QUEUE_NAME) |
| 23 | .messageHandler((ctx, message) -> { |
| 24 | String body = new String(message.body(), StandardCharsets.UTF_8); |
| 25 | System.out.println(" [x] Received '" + body + "'"); |
| 26 | ctx.accept(); |
| 27 | }) |
| 28 | .build(); |
| 29 | |
| 30 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
| 31 | consumer.close(); |
| 32 | connection.close(); |
| 33 | environment.close(); |
| 34 | })); |
| 35 | |
| 36 | Thread.sleep(Long.MAX_VALUE); |
| 37 | } |
| 38 | } |
nothing calls this directly
no test coverage detected