or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration-properties.mdconnection-configuration.mderror-handling.mdindex.mdlistener-configuration.mdmessage-operations.mdqueue-exchange-management.mdstream-processing.md

configuration-properties.mddocs/

0

# Configuration Properties

1

2

Comprehensive configuration options available through application properties for all aspects of AMQP messaging, including connection settings, listener configuration, template settings, and advanced options.

3

4

## Basic Connection Properties

5

6

### Core Connection Settings

7

8

```yaml { .api }

9

spring:

10

rabbitmq:

11

# Host and port configuration

12

host: localhost # RabbitMQ server host (default: localhost)

13

port: 5672 # RabbitMQ server port (default: 5672, 5671 for SSL)

14

username: guest # Login username (default: guest)

15

password: guest # Login password (default: guest)

16

virtual-host: / # Virtual host (default: /)

17

18

# Multiple addresses (overrides host/port if specified)

19

addresses: "amqp://guest:guest@localhost:5672,amqp://guest:guest@localhost:5673"

20

address-shuffle-mode: none # Address shuffle mode: none, random, inorder

21

22

# Connection timeouts and limits

23

connection-timeout: 60000ms # Connection timeout

24

requested-heartbeat: 60s # Heartbeat timeout (0 for none)

25

requested-channel-max: 2047 # Max channels per connection

26

channel-rpc-timeout: 10m # RPC timeout for channels

27

28

# Publisher configuration

29

publisher-confirm-type: correlated # Publisher confirms: none, simple, correlated

30

publisher-returns: true # Enable publisher returns

31

```

32

33

### SSL Configuration

34

35

```yaml { .api }

36

spring:

37

rabbitmq:

38

ssl:

39

enabled: true # Enable SSL (auto-detected from amqps:// addresses)

40

key-store: classpath:client.p12 # Path to key store

41

key-store-type: PKCS12 # Key store type (default: PKCS12)

42

key-store-password: secret # Key store password

43

key-store-algorithm: SunX509 # Key store algorithm (default: SunX509)

44

trust-store: classpath:trust.jks # Path to trust store

45

trust-store-type: JKS # Trust store type (default: JKS)

46

trust-store-password: secret # Trust store password

47

trust-store-algorithm: SunX509 # Trust store algorithm (default: SunX509)

48

algorithm: TLSv1.2 # SSL algorithm

49

validate-server-certificate: true # Validate server certificate (default: true)

50

verify-hostname: true # Verify hostname (default: true)

51

```

52

53

## Connection Caching and Pooling

54

55

### Cache Configuration

56

57

```yaml { .api }

58

spring:

59

rabbitmq:

60

cache:

61

channel:

62

size: 25 # Number of channels to cache

63

checkout-timeout: 5000ms # Channel checkout timeout

64

connection:

65

mode: channel # Cache mode: channel, connection

66

size: 1 # Number of connections to cache (CONNECTION mode)

67

```

68

69

## Listener Container Configuration

70

71

### Container Type Selection

72

73

```yaml { .api }

74

spring:

75

rabbitmq:

76

listener:

77

type: simple # Container type: simple, direct, stream

78

```

79

80

### Simple Container Configuration

81

82

```yaml { .api }

83

spring:

84

rabbitmq:

85

listener:

86

simple:

87

# Consumer configuration

88

concurrency: 1 # Minimum number of consumers

89

max-concurrency: 1 # Maximum number of consumers

90

prefetch: 1 # Number of unacked messages per consumer

91

92

# Transaction and batch configuration

93

transaction-size: 1 # Number of messages to process in a transaction

94

95

# Container behavior

96

auto-startup: true # Whether to start containers automatically

97

acknowledge-mode: auto # Acknowledge mode: auto, manual, none

98

default-requeue-rejected: true # Whether to requeue rejected messages

99

100

# Advanced settings

101

missing-queues-fatal: true # Fail if queues are missing

102

idle-event-interval: 60000ms # Idle event publishing interval

103

104

# Batching

105

consumer-batch-enabled: false # Enable consumer batching

106

batch-size: 1 # Batch size for consumer batching

107

108

# De-batching

109

de-batching-enabled: true # Enable message de-batching

110

111

# Retry configuration

112

retry:

113

enabled: false # Enable retry

114

stateless: true # Stateless retry

115

max-attempts: 3 # Maximum retry attempts

116

initial-interval: 1000ms # Initial retry interval

117

multiplier: 1.0 # Retry interval multiplier

118

max-interval: 10000ms # Maximum retry interval

119

```

120

121

### Direct Container Configuration

122

123

```yaml { .api }

124

spring:

125

rabbitmq:

126

listener:

127

direct:

128

# Consumer configuration

129

consumers-per-queue: 1 # Number of consumers per queue

130

prefetch: 1 # Number of unacked messages per consumer

131

132

# Container behavior

133

auto-startup: true # Whether to start containers automatically

134

acknowledge-mode: auto # Acknowledge mode: auto, manual, none

135

default-requeue-rejected: true # Whether to requeue rejected messages

136

137

# Advanced settings

138

missing-queues-fatal: false # Fail if queues are missing (default: false for direct)

139

idle-event-interval: 60000ms # Idle event publishing interval

140

141

# De-batching

142

de-batching-enabled: true # Enable message de-batching

143

144

# Retry configuration (same as simple)

145

retry:

146

enabled: false

147

stateless: true

148

max-attempts: 3

149

initial-interval: 1000ms

150

multiplier: 1.0

151

max-interval: 10000ms

152

```

153

154

### Stream Container Configuration

155

156

```yaml { .api }

157

spring:

158

rabbitmq:

159

listener:

160

stream:

161

auto-startup: true # Whether to start containers automatically

162

native-listener: false # Support native stream messages

163

```

164

165

## Template Configuration

166

167

### RabbitTemplate Settings

168

169

```yaml { .api }

170

spring:

171

rabbitmq:

172

template:

173

# Default destinations

174

exchange: "" # Default exchange for send operations

175

routing-key: "" # Default routing key for send operations

176

default-receive-queue: "" # Default queue for receive operations

177

178

# Timeouts

179

receive-timeout: 0ms # Receive timeout (0 for no timeout)

180

reply-timeout: 5000ms # Reply timeout for sendAndReceive operations

181

182

# Message properties

183

mandatory: false # Enable mandatory flag for messages

184

185

# Retry configuration

186

retry:

187

enabled: false # Enable retry for template operations

188

max-attempts: 3 # Maximum retry attempts

189

initial-interval: 1000ms # Initial retry interval

190

multiplier: 1.0 # Retry interval multiplier

191

max-interval: 10000ms # Maximum retry interval

192

```

193

194

## Stream Configuration

195

196

### RabbitMQ Streams Support

197

198

```yaml { .api }

199

spring:

200

rabbitmq:

201

stream:

202

host: localhost # Stream host (default: localhost)

203

port: 5552 # Stream port (default: 5552)

204

username: guest # Stream username (uses rabbitmq.username if not set)

205

password: guest # Stream password (uses rabbitmq.password if not set)

206

name: my-stream # Default stream name

207

```

208

209

## Advanced Configuration Examples

210

211

### Production Configuration

212

213

```yaml { .api }

214

spring:

215

rabbitmq:

216

# Connection configuration

217

addresses: "amqps://prod-rabbit1:5671,amqps://prod-rabbit2:5671,amqps://prod-rabbit3:5671"

218

username: ${RABBITMQ_USERNAME}

219

password: ${RABBITMQ_PASSWORD}

220

virtual-host: ${RABBITMQ_VHOST:/production}

221

222

# Connection settings

223

connection-timeout: 30s

224

requested-heartbeat: 30s

225

requested-channel-max: 100

226

227

# Publisher settings

228

publisher-confirm-type: correlated

229

publisher-returns: true

230

231

# SSL configuration

232

ssl:

233

enabled: true

234

validate-server-certificate: true

235

verify-hostname: true

236

trust-store: classpath:production-truststore.jks

237

trust-store-password: ${TRUSTSTORE_PASSWORD}

238

239

# Connection caching

240

cache:

241

channel:

242

size: 50

243

checkout-timeout: 5s

244

connection:

245

mode: connection

246

size: 5

247

248

# Listener configuration

249

listener:

250

simple:

251

concurrency: 3

252

max-concurrency: 10

253

prefetch: 5

254

acknowledge-mode: auto

255

default-requeue-rejected: false

256

missing-queues-fatal: true

257

retry:

258

enabled: true

259

max-attempts: 3

260

initial-interval: 2s

261

multiplier: 2.0

262

max-interval: 30s

263

264

# Template configuration

265

template:

266

mandatory: true

267

reply-timeout: 10s

268

retry:

269

enabled: true

270

max-attempts: 3

271

initial-interval: 1s

272

multiplier: 1.5

273

max-interval: 10s

274

```

275

276

### Development Configuration

277

278

```yaml { .api }

279

spring:

280

rabbitmq:

281

# Simple local setup

282

host: localhost

283

port: 5672

284

username: guest

285

password: guest

286

287

# Relaxed settings for development

288

listener:

289

simple:

290

concurrency: 1

291

max-concurrency: 1

292

prefetch: 1

293

missing-queues-fatal: false

294

auto-startup: true

295

296

template:

297

receive-timeout: 1s

298

reply-timeout: 5s

299

```

300

301

### High-Throughput Configuration

302

303

```yaml { .api }

304

spring:

305

rabbitmq:

306

# Connection optimization

307

requested-channel-max: 200

308

requested-heartbeat: 10s

309

310

# Aggressive caching

311

cache:

312

channel:

313

size: 100

314

checkout-timeout: 1s

315

connection:

316

mode: connection

317

size: 10

318

319

# Optimized listener settings

320

listener:

321

simple:

322

concurrency: 10

323

max-concurrency: 50

324

prefetch: 20

325

transaction-size: 10

326

consumer-batch-enabled: true

327

batch-size: 100

328

acknowledge-mode: auto

329

330

# Stream configuration for high throughput

331

stream:

332

name: high-throughput-stream

333

```

334

335

### Multi-Environment Configuration

336

337

```yaml { .api }

338

spring:

339

profiles:

340

active: ${SPRING_PROFILES_ACTIVE:development}

341

342

---

343

spring:

344

config:

345

activate:

346

on-profile: development

347

rabbitmq:

348

host: localhost

349

port: 5672

350

username: dev-user

351

password: dev-pass

352

virtual-host: /dev

353

354

---

355

spring:

356

config:

357

activate:

358

on-profile: staging

359

rabbitmq:

360

addresses: "amqp://staging-rabbit1:5672,amqp://staging-rabbit2:5672"

361

username: ${RABBITMQ_STAGING_USER}

362

password: ${RABBITMQ_STAGING_PASS}

363

virtual-host: /staging

364

listener:

365

simple:

366

concurrency: 2

367

max-concurrency: 5

368

369

---

370

spring:

371

config:

372

activate:

373

on-profile: production

374

rabbitmq:

375

addresses: "amqps://prod-rabbit1:5671,amqps://prod-rabbit2:5671,amqps://prod-rabbit3:5671"

376

username: ${RABBITMQ_PROD_USER}

377

password: ${RABBITMQ_PROD_PASS}

378

virtual-host: ${RABBITMQ_PROD_VHOST}

379

ssl:

380

enabled: true

381

trust-store: ${RABBITMQ_TRUSTSTORE_PATH}

382

trust-store-password: ${RABBITMQ_TRUSTSTORE_PASSWORD}

383

publisher-confirm-type: correlated

384

publisher-returns: true

385

listener:

386

simple:

387

concurrency: 5

388

max-concurrency: 20

389

prefetch: 10

390

```

391

392

## Configuration Validation

393

394

### Property Validation Configuration

395

396

```java { .api }

397

@Configuration

398

@EnableConfigurationProperties(RabbitProperties.class)

399

public class RabbitConfigValidation {

400

401

@Bean

402

@ConfigurationPropertiesBinding

403

public Validator configurationPropertiesValidator() {

404

return new OptionalValidatorFactoryBean();

405

}

406

}

407

408

@Component

409

@Validated

410

public class RabbitPropertiesValidator {

411

412

@Autowired

413

private RabbitProperties rabbitProperties;

414

415

@EventListener

416

public void validateOnStartup(ApplicationReadyEvent event) {

417

validateConnectionSettings();

418

validateListenerSettings();

419

validateSslSettings();

420

}

421

422

private void validateConnectionSettings() {

423

if (rabbitProperties.getHost() == null && rabbitProperties.getAddresses() == null) {

424

throw new IllegalArgumentException("Either host or addresses must be configured");

425

}

426

427

if (rabbitProperties.getPort() != null && (rabbitProperties.getPort() < 1 || rabbitProperties.getPort() > 65535)) {

428

throw new IllegalArgumentException("Port must be between 1 and 65535");

429

}

430

}

431

432

private void validateListenerSettings() {

433

RabbitProperties.SimpleContainer simple = rabbitProperties.getListener().getSimple();

434

if (simple.getConcurrency() != null && simple.getMaxConcurrency() != null) {

435

if (simple.getConcurrency() > simple.getMaxConcurrency()) {

436

throw new IllegalArgumentException("Concurrency cannot be greater than max-concurrency");

437

}

438

}

439

}

440

441

private void validateSslSettings() {

442

RabbitProperties.Ssl ssl = rabbitProperties.getSsl();

443

if (Boolean.TRUE.equals(ssl.getEnabled())) {

444

if (ssl.getTrustStore() == null && ssl.getKeyStore() == null) {

445

log.warn("SSL is enabled but no trust store or key store configured");

446

}

447

}

448

}

449

}

450

```

451

452

## Configuration Override Examples

453

454

### Programmatic Configuration Override

455

456

```java { .api }

457

@Configuration

458

public class RabbitConfigOverride {

459

460

@Bean

461

@Primary

462

public CachingConnectionFactory connectionFactory(RabbitProperties properties) {

463

CachingConnectionFactory factory = new CachingConnectionFactory();

464

465

// Override properties programmatically

466

factory.setHost(properties.determineHost());

467

factory.setPort(properties.determinePort());

468

factory.setUsername(properties.determineUsername());

469

factory.setPassword(properties.determinePassword());

470

factory.setVirtualHost(properties.determineVirtualHost());

471

472

// Custom cache settings

473

factory.setChannelCacheSize(100);

474

factory.setConnectionCacheSize(10);

475

factory.setCacheMode(CacheMode.CONNECTION);

476

477

// Publisher settings

478

factory.setPublisherConfirmType(ConfirmType.CORRELATED);

479

factory.setPublisherReturns(true);

480

481

return factory;

482

}

483

484

@Bean

485

@Primary

486

public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(

487

CachingConnectionFactory connectionFactory,

488

RabbitProperties properties) {

489

490

SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();

491

factory.setConnectionFactory(connectionFactory);

492

493

// Override listener properties

494

RabbitProperties.SimpleContainer config = properties.getListener().getSimple();

495

factory.setConcurrentConsumers(config.getConcurrency() != null ? config.getConcurrency() : 5);

496

factory.setMaxConcurrentConsumers(config.getMaxConcurrency() != null ? config.getMaxConcurrency() : 20);

497

factory.setPrefetchCount(config.getPrefetch() != null ? config.getPrefetch() : 10);

498

499

return factory;

500

}

501

}

502

```

503

504

### Environment-Specific Overrides

505

506

```java { .api }

507

@Configuration

508

public class EnvironmentSpecificConfig {

509

510

@Bean

511

@Profile("cloud")

512

public ConnectionFactoryCustomizer cloudConnectionCustomizer() {

513

return connectionFactory -> {

514

// Cloud-specific optimizations

515

connectionFactory.setRequestedHeartbeat(30);

516

connectionFactory.setConnectionTimeout(15000);

517

connectionFactory.setAutomaticRecoveryEnabled(true);

518

connectionFactory.setNetworkRecoveryInterval(2000);

519

};

520

}

521

522

@Bean

523

@Profile("kubernetes")

524

public SimpleRabbitListenerContainerFactory kubernetesContainerFactory(

525

ConnectionFactory connectionFactory) {

526

527

SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();

528

factory.setConnectionFactory(connectionFactory);

529

530

// Kubernetes-specific settings

531

factory.setConcurrentConsumers(3);

532

factory.setMaxConcurrentConsumers(10);

533

factory.setPrefetchCount(5);

534

factory.setDefaultRequeueRejected(false);

535

factory.setMissingQueuesFatal(false);

536

537

return factory;

538

}

539

}