File tree Expand file tree Collapse file tree 7 files changed +31
-2
lines changed
src/com/rabbitmq/client/impl
test/src/com/rabbitmq/client/test Expand file tree Collapse file tree 7 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,8 @@ public void transmit(AMQChannel channel) throws IOException {
121
121
}
122
122
}
123
123
}
124
+
125
+ connection .flush ();
124
126
}
125
127
126
128
@ Override public String toString () {
Original file line number Diff line number Diff line change @@ -474,6 +474,13 @@ public void writeFrame(Frame f) throws IOException {
474
474
_heartbeatSender .signalActivity ();
475
475
}
476
476
477
+ /**
478
+ * Public API - flush the output buffers
479
+ */
480
+ public void flush () throws IOException {
481
+ _frameHandler .flush ();
482
+ }
483
+
477
484
private static final int negotiatedMaxValue (int clientValue , int serverValue ) {
478
485
return (clientValue == 0 || serverValue == 0 ) ?
479
486
Math .max (clientValue , serverValue ) :
Original file line number Diff line number Diff line change @@ -71,6 +71,13 @@ public interface FrameHandler {
71
71
*/
72
72
void writeFrame (Frame frame ) throws IOException ;
73
73
74
+ /**
75
+ * Flush the underlying data connection.
76
+ *
77
+ * @throws IOException if there is a problem accessing the connection
78
+ */
79
+ void flush () throws IOException ;
80
+
74
81
/** Close the underlying data connection (complaint not permitted). */
75
82
void close ();
76
83
}
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ public void run() {
131
131
132
132
if (now > (lastActivityTime + this .heartbeatNanos )) {
133
133
frameHandler .writeFrame (new Frame (AMQP .FRAME_HEARTBEAT , 0 ));
134
+ frameHandler .flush ();
134
135
}
135
136
} catch (IOException e ) {
136
137
// ignore
Original file line number Diff line number Diff line change @@ -135,12 +135,15 @@ public Frame readFrame() throws IOException {
135
135
public void writeFrame (Frame frame ) throws IOException {
136
136
synchronized (_outputStream ) {
137
137
frame .writeTo (_outputStream );
138
- _outputStream .flush ();
139
138
}
140
139
}
141
140
141
+ public void flush () throws IOException {
142
+ _outputStream .flush ();
143
+ }
144
+
142
145
public void close () {
143
146
try { _socket .setSoLinger (true , SOCKET_CLOSING_TIMEOUT ); } catch (Exception _) {}
144
- try { _socket .close (); } catch (Exception _) {}
147
+ try { flush (); _socket .close (); } catch (Exception _) {}
145
148
}
146
149
}
Original file line number Diff line number Diff line change @@ -216,6 +216,10 @@ public InetAddress getAddress() {
216
216
public int getPort () {
217
217
return -1 ;
218
218
}
219
+
220
+ public void flush () throws IOException {
221
+ // no need to implement this: don't bother writing the frame
222
+ }
219
223
}
220
224
221
225
/** Exception handler to facilitate testing. */
Original file line number Diff line number Diff line change @@ -173,6 +173,11 @@ public InetAddress getAddress() {
173
173
public int getPort () {
174
174
return -1 ;
175
175
}
176
+
177
+ @ Override
178
+ public void flush () throws IOException {
179
+ // no need to implement this: don't bother writing the frame
180
+ }
176
181
}
177
182
178
183
}
You can’t perform that action at this time.
0 commit comments