(String[] argv)
| 13 | private static final String QUEUE_NAME = "hello"; |
| 14 | |
| 15 | public static void main(String[] argv) throws Exception { |
| 16 | Environment environment = TutorialSupport.newEnvironment(); |
| 17 | try (Connection connection = environment.connectionBuilder().uri(TutorialSupport.BROKER_URI).build()) { |
| 18 | try (Management management = connection.management()) { |
| 19 | management.queue().name(QUEUE_NAME).quorum().queue().declare(); |
| 20 | } |
| 21 | try (Publisher publisher = connection.publisherBuilder().queue(QUEUE_NAME).build()) { |
| 22 | String message = "Hello World!"; |
| 23 | Message msg = publisher.message(message.getBytes(StandardCharsets.UTF_8)); |
| 24 | CountDownLatch confirmed = new CountDownLatch(1); |
| 25 | publisher.publish(msg, ctx -> { |
| 26 | if (ctx.status() == Publisher.Status.ACCEPTED) { |
| 27 | confirmed.countDown(); |
| 28 | } |
| 29 | }); |
| 30 | if (!confirmed.await(30, TimeUnit.SECONDS)) { |
| 31 | throw new IllegalStateException("Publish was not confirmed in time"); |
| 32 | } |
| 33 | System.out.println(" [x] Sent '" + message + "'"); |
| 34 | } |
| 35 | } finally { |
| 36 | environment.close(); |
| 37 | } |
| 38 | } |
| 39 | } |
nothing calls this directly
no test coverage detected