@@ -89,9 +89,9 @@ public Response handle(Object reply) {
89
89
/**
90
90
* Generates correlation ID for each request.
91
91
*
92
- * @since 5.9 .0
92
+ * @since 4.12 .0
93
93
*/
94
- private final Supplier < String > _correlationIdGenerator ;
94
+ private final CorrelationIdSupplier _correlationIdSupplier ;
95
95
96
96
private String lastCorrelationId = "0" ;
97
97
@@ -118,7 +118,7 @@ public RpcClient(RpcClientParams params) throws
118
118
_timeout = params .getTimeout ();
119
119
_useMandatory = params .shouldUseMandatory ();
120
120
_replyHandler = params .getReplyHandler ();
121
- _correlationIdGenerator = params .getCorrelationIdSupplier ();
121
+ _correlationIdSupplier = params .getCorrelationIdSupplier ();
122
122
123
123
_consumer = setupConsumer ();
124
124
if (_useMandatory ) {
@@ -304,7 +304,7 @@ public Response doCall(AMQP.BasicProperties props, byte[] message, int timeout)
304
304
BlockingCell <Object > k = new BlockingCell <Object >();
305
305
String replyId ;
306
306
synchronized (_continuationMap ) {
307
- replyId = _correlationIdGenerator .get ();
307
+ replyId = _correlationIdSupplier .get ();
308
308
lastCorrelationId = replyId ;
309
309
props = ((props ==null ) ? new AMQP .BasicProperties .Builder () : props .builder ())
310
310
.correlationId (replyId ).replyTo (_replyTo ).build ();
@@ -488,16 +488,16 @@ public Map<String, BlockingCell<Object>> getContinuationMap() {
488
488
/**
489
489
* Retrieve the last correlation id used.
490
490
* <p>
491
- * Note as of 5.9 .0, correlation IDs may not always be integers
491
+ * Note as of 4.12 .0, correlation IDs may not always be integers
492
492
* (by default, they are).
493
493
* This method will try to parse the last correlation ID string
494
494
* as an integer, so this may result in {@link NumberFormatException}
495
495
* if the correlation ID supplier provided by
496
- * {@link RpcClientParams#correlationIdSupplier(Supplier )}
496
+ * {@link RpcClientParams#correlationIdSupplier(CorrelationIdSupplier )}
497
497
* does not generate appropriate IDs.
498
498
*
499
499
* @return the most recently used correlation id
500
- * @see RpcClientParams#correlationIdSupplier(Supplier)
500
+ * @see RpcClientParams#correlationIdSupplier(CorrelationIdSupplier)
501
501
*/
502
502
public int getCorrelationId () {
503
503
return Integer .valueOf (this .lastCorrelationId );
@@ -569,14 +569,25 @@ public interface RpcClientReplyHandler {
569
569
570
570
}
571
571
572
+ /**
573
+ * Contract to generate correlation IDs.
574
+ *
575
+ * @since 4.12.0
576
+ */
577
+ public interface CorrelationIdSupplier {
578
+
579
+ String get ();
580
+
581
+ }
582
+
572
583
/**
573
584
* Creates generation IDs as a sequence of integers.
574
585
*
575
586
* @return
576
- * @see RpcClientParams#correlationIdSupplier(Supplier )
577
- * @since 5.9 .0
587
+ * @see RpcClientParams#correlationIdSupplier(CorrelationIdSupplier )
588
+ * @since 4.12 .0
578
589
*/
579
- public static Supplier < String > incrementingCorrelationIdSupplier () {
590
+ public static CorrelationIdSupplier incrementingCorrelationIdSupplier () {
580
591
return incrementingCorrelationIdSupplier ("" );
581
592
}
582
593
@@ -585,17 +596,17 @@ public static Supplier<String> incrementingCorrelationIdSupplier() {
585
596
*
586
597
* @param prefix
587
598
* @return
588
- * @see RpcClientParams#correlationIdSupplier(Supplier )
589
- * @since 5.9 .0
599
+ * @see RpcClientParams#correlationIdSupplier(CorrelationIdSupplier )
600
+ * @since 4.12 .0
590
601
*/
591
- public static Supplier < String > incrementingCorrelationIdSupplier (String prefix ) {
602
+ public static CorrelationIdSupplier incrementingCorrelationIdSupplier (String prefix ) {
592
603
return new IncrementingCorrelationIdSupplier (prefix );
593
604
}
594
605
595
606
/**
596
- * @since 5.9 .0
607
+ * @since 4.12 .0
597
608
*/
598
- private static class IncrementingCorrelationIdSupplier implements Supplier < String > {
609
+ private static class IncrementingCorrelationIdSupplier implements CorrelationIdSupplier {
599
610
600
611
private final String prefix ;
601
612
private int correlationId ;
0 commit comments