Skip to content

Commit d38cc9a

Browse files
Initialize heartbeat sender in #start
This gives ConnectionFactory a chance to set a ThreadFactory first.
1 parent 0982bf4 commit d38cc9a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static final Map<String, Object> defaultClientProperties() {
127127
private volatile boolean _inConnectionNegotiation;
128128

129129
/** Manages heart-beat sending for this connection */
130-
private final HeartbeatSender _heartbeatSender;
130+
private HeartbeatSender _heartbeatSender;
131131

132132
private final String _virtualHost;
133133
private final Map<String, Object> _clientProperties;
@@ -219,12 +219,15 @@ public AMQConnection(ConnectionParams params, FrameHandler frameHandler)
219219
this._workService = new ConsumerWorkService(params.getExecutor());
220220
this._channelManager = null;
221221

222-
this._heartbeatSender = new HeartbeatSender(frameHandler, threadFactory);
223222
this._brokerInitiatedShutdown = false;
224223

225224
this._inConnectionNegotiation = true; // we start out waiting for the first protocol response
226225
}
227226

227+
private void initializeHeartbeatSender(FrameHandler frameHandler) {
228+
this._heartbeatSender = new HeartbeatSender(frameHandler, threadFactory);
229+
}
230+
228231
/**
229232
* Start up the connection, including the MainLoop thread.
230233
* Sends the protocol
@@ -244,6 +247,7 @@ public AMQConnection(ConnectionParams params, FrameHandler frameHandler)
244247
public void start()
245248
throws IOException
246249
{
250+
initializeHeartbeatSender(_frameHandler);
247251
this._running = true;
248252
// Make sure that the first thing we do is to send the header,
249253
// which should cause any socket errors to show up for us, rather

0 commit comments

Comments
 (0)