63
63
*/
64
64
public class AmqpInboundGateway extends MessagingGatewaySupport {
65
65
66
- private static final ThreadLocal <AttributeAccessor > attributesHolder = new ThreadLocal <AttributeAccessor >();
66
+ private static final ThreadLocal <AttributeAccessor > attributesHolder = new ThreadLocal <>();
67
67
68
68
private final AbstractMessageListenerContainer messageListenerContainer ;
69
69
@@ -203,11 +203,13 @@ protected void onInit() {
203
203
204
204
@ Override
205
205
protected void doStart () {
206
+ super .doStart ();
206
207
this .messageListenerContainer .start ();
207
208
}
208
209
209
210
@ Override
210
211
protected void doStop () {
212
+ super .doStop ();
211
213
this .messageListenerContainer .stop ();
212
214
}
213
215
@@ -269,18 +271,18 @@ public void onMessage(final Message message, final Channel channel) throws Excep
269
271
org .springframework .messaging .Message <Object > converted = convert (message , channel );
270
272
if (converted != null ) {
271
273
AmqpInboundGateway .this .retryTemplate .execute (context -> {
272
- StaticMessageHeaderAccessor .getDeliveryAttempt (converted ).incrementAndGet ();
273
- process (message , converted );
274
- return null ;
275
- },
276
- (RecoveryCallback <Object >) AmqpInboundGateway .this .recoveryCallback );
274
+ StaticMessageHeaderAccessor .getDeliveryAttempt (converted ).incrementAndGet ();
275
+ process (message , converted );
276
+ return null ;
277
+ },
278
+ (RecoveryCallback <Object >) AmqpInboundGateway .this .recoveryCallback );
277
279
}
278
280
}
279
281
}
280
282
281
283
private org .springframework .messaging .Message <Object > convert (Message message , Channel channel ) {
282
- Map <String , Object > headers = null ;
283
- Object payload = null ;
284
+ Map <String , Object > headers ;
285
+ Object payload ;
284
286
boolean isManualAck = AmqpInboundGateway .this .messageListenerContainer
285
287
.getAcknowledgeMode () == AcknowledgeMode .MANUAL ;
286
288
try {
@@ -299,17 +301,17 @@ private org.springframework.messaging.Message<Object> convert(Message message, C
299
301
if (errorChannel != null ) {
300
302
setAttributesIfNecessary (message , null );
301
303
AmqpInboundGateway .this .messagingTemplate .send (errorChannel , buildErrorMessage (null ,
302
- EndpointUtils .errorMessagePayload (message , channel , isManualAck , e )));
304
+ EndpointUtils .errorMessagePayload (message , channel , isManualAck , e )));
303
305
}
304
306
else {
305
307
throw e ;
306
308
}
307
309
return null ;
308
310
}
309
311
return getMessageBuilderFactory ()
310
- .withPayload (payload )
311
- .copyHeaders (headers )
312
- .build ();
312
+ .withPayload (payload )
313
+ .copyHeaders (headers )
314
+ .build ();
313
315
}
314
316
315
317
private void process (Message message , org .springframework .messaging .Message <Object > messagingMessage ) {
0 commit comments