or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

actuator.mdconfiguration.mdcore-messaging.mdindex.mdlisteners.mdstreams.md

configuration.mddocs/

0

# Configuration Properties

1

2

Comprehensive configuration options for RabbitMQ connections, caching, SSL, retry behavior, and message handling through Spring Boot properties under the `spring.rabbitmq` prefix.

3

4

## Capabilities

5

6

### Connection Properties

7

8

Basic connection configuration for RabbitMQ server connectivity.

9

10

```java { .api }

11

/**

12

* Main RabbitMQ connection properties

13

*/

14

@ConfigurationProperties("spring.rabbitmq")

15

public class RabbitProperties {

16

17

/** RabbitMQ host (default: localhost) */

18

private String host = "localhost";

19

20

/** RabbitMQ port (default: 5672, or 5671 if SSL enabled) */

21

private Integer port;

22

23

/** Login username (default: guest) */

24

private String username = "guest";

25

26

/** Login password (default: guest) */

27

private String password = "guest";

28

29

/** Virtual host to use when connecting */

30

private String virtualHost;

31

32

/** List of addresses for cluster connections (overrides host/port) */

33

private List<String> addresses;

34

35

/** Address shuffle mode for cluster connections */

36

private AddressShuffleMode addressShuffleMode = AddressShuffleMode.NONE;

37

38

/** Requested heartbeat timeout (default: server default) */

39

private Duration requestedHeartbeat;

40

41

/** Number of channels per connection (default: 2047, 0 for unlimited) */

42

private int requestedChannelMax = 2047;

43

44

/** Connection timeout (default: 60s) */

45

private Duration connectionTimeout;

46

47

/** RPC timeout for channel operations (default: 10 minutes) */

48

private Duration channelRpcTimeout = Duration.ofMinutes(10);

49

50

/** Maximum inbound message body size (default: 64MB) */

51

private DataSize maxInboundMessageBodySize = DataSize.ofMegabytes(64);

52

}

53

```

54

55

**Configuration Example:**

56

57

```yaml

58

spring:

59

rabbitmq:

60

host: rabbitmq.example.com

61

port: 5672

62

username: myapp

63

password: ${RABBITMQ_PASSWORD}

64

virtual-host: /production

65

connection-timeout: 30s

66

requested-heartbeat: 30s

67

```

68

69

### SSL Configuration

70

71

SSL/TLS configuration for secure connections to RabbitMQ.

72

73

```java { .api }

74

/**

75

* SSL configuration properties

76

*/

77

public static class Ssl {

78

79

/** Enable SSL support */

80

private Boolean enabled;

81

82

/** Path to key store */

83

private String keyStore;

84

85

/** Key store type (JKS, PKCS12, etc.) */

86

private String keyStoreType;

87

88

/** Key store password */

89

private String keyStorePassword;

90

91

/** Path to trust store */

92

private String trustStore;

93

94

/** Trust store type */

95

private String trustStoreType;

96

97

/** Trust store password */

98

private String trustStorePassword;

99

100

/** SSL algorithm to use */

101

private String algorithm;

102

103

/** Validate server certificate */

104

private boolean validateServerCertificate = true;

105

106

/** Verify hostname */

107

private boolean verifyHostname = true;

108

109

/** SSL bundle name for SSL configuration (Spring Boot 3.1+) */

110

private String bundle;

111

}

112

```

113

114

**SSL Configuration Example:**

115

116

```yaml

117

spring:

118

rabbitmq:

119

host: secure-rabbitmq.example.com

120

port: 5671

121

ssl:

122

enabled: true

123

bundle: rabbitmq-ssl

124

validate-server-certificate: true

125

verify-hostname: true

126

```

127

128

**SSL Bundle Configuration (Spring Boot 3.1+):**

129

130

SSL bundles provide a centralized way to configure SSL certificates and can be referenced by name:

131

132

```yaml

133

spring:

134

ssl:

135

bundle:

136

jks:

137

rabbitmq-ssl:

138

keystore:

139

location: classpath:rabbitmq-keystore.jks

140

password: ${KEYSTORE_PASSWORD}

141

truststore:

142

location: classpath:rabbitmq-truststore.jks

143

password: ${TRUSTSTORE_PASSWORD}

144

rabbitmq:

145

ssl:

146

enabled: true

147

bundle: rabbitmq-ssl # Reference to the SSL bundle above

148

```

149

150

**Alternative PEM Bundle Configuration:**

151

152

```yaml

153

spring:

154

ssl:

155

bundle:

156

pem:

157

rabbitmq-ssl:

158

keystore:

159

certificate: classpath:client-cert.pem

160

private-key: classpath:client-key.pem

161

truststore:

162

certificate: classpath:ca-cert.pem

163

rabbitmq:

164

ssl:

165

enabled: true

166

bundle: rabbitmq-ssl

167

```

168

169

### Connection Caching

170

171

Connection and channel caching configuration for connection pooling and resource management.

172

173

```java { .api }

174

/**

175

* Cache configuration properties

176

*/

177

public static class Cache {

178

179

/** Connection cache configuration */

180

private final Connection connection = new Connection();

181

182

/** Channel cache configuration */

183

private final Channel channel = new Channel();

184

185

/**

186

* Connection cache properties

187

*/

188

public static class Connection {

189

190

/** Connection cache mode (CHANNEL or CONNECTION) */

191

private CacheMode mode = CacheMode.CHANNEL;

192

193

/** Connection cache size (when mode is CONNECTION) */

194

private Integer size;

195

}

196

197

/**

198

* Channel cache properties

199

*/

200

public static class Channel {

201

202

/** Channel cache size per connection */

203

private Integer size;

204

205

/** Checkout timeout for channels */

206

private Duration checkoutTimeout;

207

}

208

}

209

```

210

211

**Caching Configuration Example:**

212

213

```yaml

214

spring:

215

rabbitmq:

216

cache:

217

connection:

218

mode: connection

219

size: 10

220

channel:

221

size: 50

222

checkout-timeout: 5s

223

```

224

225

### Publisher Configuration

226

227

Configuration for publisher confirms and returns for reliable message delivery.

228

229

```java { .api }

230

/**

231

* Publisher-related properties in RabbitProperties

232

*/

233

// Within RabbitProperties class:

234

235

/** Enable publisher returns (for undeliverable messages) */

236

private boolean publisherReturns;

237

238

/** Type of publisher confirms to use */

239

private ConfirmType publisherConfirmType;

240

241

/**

242

* Publisher confirm types

243

*/

244

public enum ConfirmType {

245

/** No publisher confirms */

246

NONE,

247

/** Simple publisher confirms */

248

SIMPLE,

249

/** Correlated publisher confirms */

250

CORRELATED

251

}

252

```

253

254

**Publisher Configuration Example:**

255

256

```yaml

257

spring:

258

rabbitmq:

259

publisher-returns: true

260

publisher-confirm-type: correlated

261

```

262

263

### Template Configuration

264

265

RabbitTemplate-specific configuration for message operations.

266

267

```java { .api }

268

/**

269

* Template configuration properties

270

*/

271

public static class Template {

272

273

/** Enable mandatory flag for messages */

274

private Boolean mandatory;

275

276

/** Receive timeout for synchronous receives */

277

private Duration receiveTimeout;

278

279

/** Reply timeout for sendAndReceive operations */

280

private Duration replyTimeout;

281

282

/** Default exchange for send operations */

283

private String exchange = "";

284

285

/** Default routing key for send operations */

286

private String routingKey = "";

287

288

/** Default receive queue */

289

private String defaultReceiveQueue;

290

291

/** Retry configuration */

292

private final Retry retry = new Retry();

293

}

294

```

295

296

**Template Configuration Example:**

297

298

```yaml

299

spring:

300

rabbitmq:

301

template:

302

mandatory: true

303

receive-timeout: 10s

304

reply-timeout: 30s

305

exchange: default.exchange

306

routing-key: default.key

307

```

308

309

### Retry Configuration

310

311

Retry configuration for failed message operations and listener recovery.

312

313

```java { .api }

314

/**

315

* Retry configuration properties

316

*/

317

public static class Retry {

318

319

/** Enable retry */

320

private boolean enabled;

321

322

/** Maximum number of attempts */

323

private int maxAttempts = 3;

324

325

/** Initial retry interval */

326

private Duration initialInterval = Duration.ofSeconds(1);

327

328

/** Retry interval multiplier */

329

private double multiplier = 1.0;

330

331

/** Maximum retry interval */

332

private Duration maxInterval = Duration.ofSeconds(10);

333

}

334

335

/**

336

* Listener-specific retry configuration

337

*/

338

public static class ListenerRetry extends Retry {

339

340

/** Whether retries are stateless */

341

private Boolean stateless = true;

342

}

343

```

344

345

**Retry Configuration Example:**

346

347

```yaml

348

spring:

349

rabbitmq:

350

template:

351

retry:

352

enabled: true

353

max-attempts: 5

354

initial-interval: 2s

355

multiplier: 2.0

356

max-interval: 30s

357

listener:

358

simple:

359

retry:

360

enabled: true

361

max-attempts: 3

362

initial-interval: 1s

363

stateless: false

364

```

365

366

### Customizer Interfaces

367

368

Programmatic configuration through customizer interfaces.

369

370

```java { .api }

371

/**

372

* Customizer for RabbitMQ connection factory

373

*/

374

@FunctionalInterface

375

public interface ConnectionFactoryCustomizer {

376

void customize(com.rabbitmq.client.ConnectionFactory connectionFactory);

377

}

378

379

/**

380

* Customizer for RabbitTemplate

381

*/

382

@FunctionalInterface

383

public interface RabbitTemplateCustomizer {

384

void customize(RabbitTemplate rabbitTemplate);

385

}

386

387

/**

388

* Customizer for retry templates

389

*/

390

@FunctionalInterface

391

public interface RabbitRetryTemplateCustomizer {

392

void customize(Target target, RetryTemplate retryTemplate);

393

394

enum Target {

395

SENDER, LISTENER

396

}

397

}

398

399

/**

400

* Customizer for RabbitMQ environment

401

*/

402

@FunctionalInterface

403

public interface EnvironmentBuilderCustomizer {

404

void customize(Environment.EnvironmentBuilder builder);

405

}

406

```

407

408

**Customizer Usage Example:**

409

410

```java

411

import org.springframework.boot.autoconfigure.amqp.*;

412

import org.springframework.context.annotation.Bean;

413

import org.springframework.context.annotation.Configuration;

414

415

@Configuration

416

public class RabbitCustomizerConfig {

417

418

@Bean

419

public ConnectionFactoryCustomizer connectionFactoryCustomizer() {

420

return factory -> {

421

factory.setRequestedChannelMax(1000);

422

factory.setNetworkRecoveryInterval(10000);

423

};

424

}

425

426

@Bean

427

public RabbitTemplateCustomizer rabbitTemplateCustomizer() {

428

return template -> {

429

template.setMandatory(true);

430

template.setUserIdExpression(new LiteralExpression("system"));

431

};

432

}

433

434

@Bean

435

public RabbitRetryTemplateCustomizer retryTemplateCustomizer() {

436

return (target, retryTemplate) -> {

437

if (target == RabbitRetryTemplateCustomizer.Target.LISTENER) {

438

retryTemplate.registerListener(new CustomRetryListener());

439

}

440

};

441

}

442

}

443

```

444

445

### Stream Configuration

446

447

Configuration for RabbitMQ Streams support.

448

449

```java { .api }

450

/**

451

* Stream configuration properties

452

*/

453

public static class Stream {

454

455

/** Stream host (defaults to main host) */

456

private String host;

457

458

/** Stream port (default: 5552) */

459

private int port = 5552;

460

461

/** Stream username */

462

private String username;

463

464

/** Stream password */

465

private String password;

466

467

/** Stream name */

468

private String name;

469

}

470

```

471

472

**Stream Configuration Example:**

473

474

```yaml

475

spring:

476

rabbitmq:

477

stream:

478

host: stream.rabbitmq.example.com

479

port: 5552

480

username: stream-user

481

password: ${STREAM_PASSWORD}

482

name: main-stream

483

```