@@ -40,6 +40,7 @@ public void openConnection()
4040 throws IOException , TimeoutException {
4141 try {
4242 connectionFactory .useSslProtocol ();
43+ connectionFactory .useNio ();
4344 } catch (Exception ex ) {
4445 throw new IOException (ex .toString ());
4546 }
@@ -55,15 +56,15 @@ public void openConnection()
5556 }
5657 }
5758 if (connection == null ) {
58- fail ("Couldn't open TLS connection after 3 attemps " );
59+ fail ("Couldn't open TLS connection after 3 attempts " );
5960 }
6061
6162 }
6263
6364 @ Test
6465 public void connectionGetConsume () throws Exception {
6566 CountDownLatch latch = new CountDownLatch (1 );
66- connection = basicGetBasicConsume (connection , "tls.nio.queue" , latch );
67+ connection = basicGetBasicConsume (connection , "tls.nio.queue" , latch , 100 * 1000 );
6768 boolean messagesReceived = latch .await (5 , TimeUnit .SECONDS );
6869 assertTrue ("Message has not been received" , messagesReceived );
6970 }
@@ -94,20 +95,31 @@ public void configure(SSLEngine sslEngine) throws IOException {
9495 }
9596 }
9697
97- private Connection basicGetBasicConsume (Connection connection , String queue , final CountDownLatch latch )
98+ @ Test public void messageSize () throws Exception {
99+ int [] sizes = new int [] {100 , 1000 , 10 * 1000 , 1 * 1000 * 1000 , 5 * 1000 * 1000 };
100+ for (int size : sizes ) {
101+ CountDownLatch latch = new CountDownLatch (1 );
102+ connection = basicGetBasicConsume (connection , "tls.nio.queue" , latch , size );
103+ boolean messagesReceived = latch .await (5 , TimeUnit .SECONDS );
104+ assertTrue ("Message has not been received" , messagesReceived );
105+ }
106+ }
107+
108+ private Connection basicGetBasicConsume (Connection connection , String queue , final CountDownLatch latch , int msgSize )
98109 throws IOException , TimeoutException {
99110 Channel channel = connection .createChannel ();
100111 channel .queueDeclare (queue , false , false , false , null );
101112 channel .queuePurge (queue );
102113
103- channel .basicPublish ("" , queue , null , new byte [100 * 1000 ]);
114+ channel .basicPublish ("" , queue , null , new byte [msgSize ]);
104115
105116 channel .basicConsume (queue , false , new DefaultConsumer (channel ) {
106117
107118 @ Override
108119 public void handleDelivery (String consumerTag , Envelope envelope , AMQP .BasicProperties properties , byte [] body ) throws IOException {
109120 getChannel ().basicAck (envelope .getDeliveryTag (), false );
110121 latch .countDown ();
122+ getChannel ().basicCancel (consumerTag );
111123 }
112124 });
113125
0 commit comments