30
30
import java .util .concurrent .ExecutorService ;
31
31
import java .util .concurrent .TimeoutException ;
32
32
33
+ import com .rabbitmq .client .impl .AMQBasicProperties ;
33
34
import com .rabbitmq .client .test .TestUtils ;
34
35
import org .junit .Test ;
35
36
@@ -104,9 +105,10 @@ public FrameMax() {
104
105
closeChannel ();
105
106
closeConnection ();
106
107
ConnectionFactory cf = new GenerousConnectionFactory ();
108
+ cf .setRequestedFrameMax (8192 );
107
109
connection = cf .newConnection ();
108
110
openChannel ();
109
- basicPublishVolatile (new byte [connection .getFrameMax ()], "void" );
111
+ basicPublishVolatile (new byte [connection .getFrameMax () * 2 ], "void" );
110
112
expectError (AMQP .FRAME_ERROR );
111
113
}
112
114
@@ -123,7 +125,9 @@ public FrameMax() {
123
125
124
126
// create headers with zero-length value to calculate maximum header value size before exceeding frame_max
125
127
headers .put (headerName , LongStringHelper .asLongString (new byte [0 ]));
126
- AMQP .BasicProperties properties = new AMQP .BasicProperties .Builder ().headers (headers ).build ();
128
+ AMQP .BasicProperties properties = new AMQP .BasicProperties .Builder ()
129
+ .headers (headers )
130
+ .build ();
127
131
Frame minimalHeaderFrame = properties .toFrame (0 , 0 );
128
132
int maxHeaderValueSize = FRAME_MAX - minimalHeaderFrame .size ();
129
133
@@ -151,6 +155,33 @@ public FrameMax() {
151
155
}
152
156
153
157
158
+ // see rabbitmq/rabbitmq-java-client#407
159
+ @ Test public void unlimitedFrameMaxWithHeaders ()
160
+ throws IOException , TimeoutException {
161
+ closeChannel ();
162
+ closeConnection ();
163
+ ConnectionFactory cf = newConnectionFactory ();
164
+ cf .setRequestedFrameMax (0 );
165
+ connection = cf .newConnection ();
166
+ openChannel ();
167
+
168
+ Map <String , Object > headers = new HashMap <String , Object >();
169
+ headers .put ("h1" , LongStringHelper .asLongString (new byte [250 ]));
170
+ headers .put ("h1" , LongStringHelper .asLongString (new byte [500 ]));
171
+ headers .put ("h1" , LongStringHelper .asLongString (new byte [750 ]));
172
+ headers .put ("h1" , LongStringHelper .asLongString (new byte [5000 ]));
173
+ headers .put ("h1" , LongStringHelper .asLongString (new byte [50000 ]));
174
+ AMQP .BasicProperties properties = new AMQP .BasicProperties .Builder ()
175
+ .headers (headers )
176
+ .build ();
177
+ basicPublishVolatile (new byte [500000 ], "" , "" , properties );
178
+ }
179
+
180
+ @ Override
181
+ protected boolean isAutomaticRecoveryEnabled () {
182
+ return false ;
183
+ }
184
+
154
185
/* ConnectionFactory that uses MyFrameHandler rather than
155
186
* SocketFrameHandler. */
156
187
private static class MyConnectionFactory extends ConnectionFactory {
0 commit comments