@@ -89,9 +89,9 @@ public Response handle(Object reply) {
8989 /**
9090 * Generates correlation ID for each request.
9191 *
92- * @since 5.9 .0
92+ * @since 4.12 .0
9393 */
94- private final Supplier < String > _correlationIdGenerator ;
94+ private final CorrelationIdSupplier _correlationIdSupplier ;
9595
9696 private String lastCorrelationId = "0" ;
9797
@@ -118,7 +118,7 @@ public RpcClient(RpcClientParams params) throws
118118 _timeout = params .getTimeout ();
119119 _useMandatory = params .shouldUseMandatory ();
120120 _replyHandler = params .getReplyHandler ();
121- _correlationIdGenerator = params .getCorrelationIdSupplier ();
121+ _correlationIdSupplier = params .getCorrelationIdSupplier ();
122122
123123 _consumer = setupConsumer ();
124124 if (_useMandatory ) {
@@ -304,7 +304,7 @@ public Response doCall(AMQP.BasicProperties props, byte[] message, int timeout)
304304 BlockingCell <Object > k = new BlockingCell <Object >();
305305 String replyId ;
306306 synchronized (_continuationMap ) {
307- replyId = _correlationIdGenerator .get ();
307+ replyId = _correlationIdSupplier .get ();
308308 lastCorrelationId = replyId ;
309309 props = ((props ==null ) ? new AMQP .BasicProperties .Builder () : props .builder ())
310310 .correlationId (replyId ).replyTo (_replyTo ).build ();
@@ -488,16 +488,16 @@ public Map<String, BlockingCell<Object>> getContinuationMap() {
488488 /**
489489 * Retrieve the last correlation id used.
490490 * <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
492492 * (by default, they are).
493493 * This method will try to parse the last correlation ID string
494494 * as an integer, so this may result in {@link NumberFormatException}
495495 * if the correlation ID supplier provided by
496- * {@link RpcClientParams#correlationIdSupplier(Supplier )}
496+ * {@link RpcClientParams#correlationIdSupplier(CorrelationIdSupplier )}
497497 * does not generate appropriate IDs.
498498 *
499499 * @return the most recently used correlation id
500- * @see RpcClientParams#correlationIdSupplier(Supplier)
500+ * @see RpcClientParams#correlationIdSupplier(CorrelationIdSupplier)
501501 */
502502 public int getCorrelationId () {
503503 return Integer .valueOf (this .lastCorrelationId );
@@ -569,14 +569,25 @@ public interface RpcClientReplyHandler {
569569
570570 }
571571
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+
572583 /**
573584 * Creates generation IDs as a sequence of integers.
574585 *
575586 * @return
576- * @see RpcClientParams#correlationIdSupplier(Supplier )
577- * @since 5.9 .0
587+ * @see RpcClientParams#correlationIdSupplier(CorrelationIdSupplier )
588+ * @since 4.12 .0
578589 */
579- public static Supplier < String > incrementingCorrelationIdSupplier () {
590+ public static CorrelationIdSupplier incrementingCorrelationIdSupplier () {
580591 return incrementingCorrelationIdSupplier ("" );
581592 }
582593
@@ -585,17 +596,17 @@ public static Supplier<String> incrementingCorrelationIdSupplier() {
585596 *
586597 * @param prefix
587598 * @return
588- * @see RpcClientParams#correlationIdSupplier(Supplier )
589- * @since 5.9 .0
599+ * @see RpcClientParams#correlationIdSupplier(CorrelationIdSupplier )
600+ * @since 4.12 .0
590601 */
591- public static Supplier < String > incrementingCorrelationIdSupplier (String prefix ) {
602+ public static CorrelationIdSupplier incrementingCorrelationIdSupplier (String prefix ) {
592603 return new IncrementingCorrelationIdSupplier (prefix );
593604 }
594605
595606 /**
596- * @since 5.9 .0
607+ * @since 4.12 .0
597608 */
598- private static class IncrementingCorrelationIdSupplier implements Supplier < String > {
609+ private static class IncrementingCorrelationIdSupplier implements CorrelationIdSupplier {
599610
600611 private final String prefix ;
601612 private int correlationId ;
0 commit comments