@@ -102,6 +102,16 @@ public void cleanUp() throws IOException, InterruptedException {
102102
103103 protected RabbitTemplate getCustomRabbitTemplate (String p12Path , String p12Passphrase )
104104 throws Exception {
105+ return getCustomRabbitTemplate (
106+ p12Path , p12Passphrase , CachingConnectionFactory .ConfirmType .NONE );
107+ }
108+
109+ // overload for tests needing setConfirmCallback (e.g.
110+ // publishWithAuthorizedButInconsistentRoutingKeyFails) to observe a broker-side nack,
111+ // independently of the Dispatcher's own publisher-confirm-type setting
112+ protected RabbitTemplate getCustomRabbitTemplate (
113+ String p12Path , String p12Passphrase , CachingConnectionFactory .ConfirmType confirmType )
114+ throws Exception {
105115 com .rabbitmq .client .ConnectionFactory cf = new com .rabbitmq .client .ConnectionFactory ();
106116 cf .setHost (rabbitMQContainer .getHost ());
107117 cf .setPort (rabbitMQContainer .getAmqpsPort ());
@@ -112,7 +122,7 @@ protected RabbitTemplate getCustomRabbitTemplate(String p12Path, String p12Passp
112122
113123 cf .setSaslConfig (DefaultSaslConfig .EXTERNAL );
114124 CachingConnectionFactory ccf = new CachingConnectionFactory (cf );
115- ccf .setPublisherConfirmType (CachingConnectionFactory . ConfirmType . CORRELATED );
125+ ccf .setPublisherConfirmType (confirmType );
116126 ccf .setPublisherReturns (true );
117127
118128 return new RabbitTemplate (ccf );
@@ -152,7 +162,6 @@ public void initialize(ConfigurableApplicationContext applicationContext) {
152162
153163 // must be set to handle PublisherConfirms in other RabbitTemplates,
154164 // even if we don't use it in Dispatcher
155- "spring.rabbitmq.publisher-confirm-type=correlated" ,
156165 "spring.rabbitmq.publisher-returns=true" ,
157166 "spring.rabbitmq.template.mandatory=true" ,
158167 "spring.rabbitmq.virtual-host=15-15_v2.1" ,
0 commit comments