|
22 | 22 | import com.rabbitmq.client.Connection; |
23 | 23 | import com.rabbitmq.client.ConnectionFactory; |
24 | 24 | import com.rabbitmq.client.WriteListener; |
25 | | -import io.netty.buffer.ByteBuf; |
26 | | -import io.netty.buffer.ByteBufAllocator; |
27 | 25 | import java.io.IOException; |
28 | 26 | import java.nio.ByteBuffer; |
29 | 27 | import java.util.UUID; |
@@ -89,40 +87,4 @@ public void publishByteBuffer() throws Exception { |
89 | 87 | this.channel.basicCancel(ctag); |
90 | 88 | } |
91 | 89 | } |
92 | | - |
93 | | - @Test |
94 | | - public void publish() throws Exception { |
95 | | - int size = 50_000; |
96 | | - byte[] masterData = new byte[size]; |
97 | | - ThreadLocalRandom.current().nextBytes(masterData); |
98 | | - ConnectionFactory cf = TestUtils.connectionFactory(); |
99 | | - ByteBufAllocator allocator = ByteBufAllocator.DEFAULT; |
100 | | - try (Connection connection = cf.newConnection()) { |
101 | | - AtomicReference<CountDownLatch> consumingLatch = new AtomicReference<>(); |
102 | | - AtomicReference<byte[]> dataRef = new AtomicReference<>(); |
103 | | - String ctag = |
104 | | - this.channel.basicConsume( |
105 | | - queue, |
106 | | - true, |
107 | | - (consumerTag, delivery) -> { |
108 | | - dataRef.set(delivery.getBody()); |
109 | | - consumingLatch.get().countDown(); |
110 | | - }, |
111 | | - consumerTag -> {}); |
112 | | - Channel publishingChannel = connection.createChannel(); |
113 | | - boolean keepGoing = true; |
114 | | - while (keepGoing) { |
115 | | - ByteBuf buf = allocator.directBuffer(size); |
116 | | - // ByteBuf buf = allocator.heapBuffer(size); |
117 | | - buf.writeBytes(masterData); |
118 | | - consumingLatch.set(new CountDownLatch(1)); |
119 | | - publishingChannel.basicPublish("", queue, null, buf.nioBuffer()); |
120 | | - assertTrue( |
121 | | - consumingLatch.get().await(10, TimeUnit.SECONDS), "deliver should have been called"); |
122 | | - buf.release(); |
123 | | - } |
124 | | - |
125 | | - this.channel.basicCancel(ctag); |
126 | | - } |
127 | | - } |
128 | 90 | } |
0 commit comments