Class CorrelationData
- java.lang.Object
-
- org.springframework.amqp.rabbit.connection.CorrelationData
-
- All Implemented Interfaces:
Correlation
public class CorrelationData extends Object implements Correlation
Base class for correlating publisher confirms to sent messages. Use theRabbitTemplate
methods that include one of these as a parameter; when the publisher confirm is received, the CorrelationData is returned with the ack/nack. When returns are also enabled, thereturned
property will be populated when a message can't be delivered - the return always arrives before the confirmation. In this case the#id
property must be set to a unique value. If no id is provided it will automatically set to a unique value.- Since:
- 1.0.1
- Author:
- Gary Russell
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CorrelationData.Confirm
Represents a publisher confirmation.
-
Constructor Summary
Constructors Constructor Description CorrelationData()
Construct an instance with a null Id.CorrelationData(String id)
Construct an instance with the supplied id.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SettableListenableFuture<CorrelationData.Confirm>
getFuture()
Return a future to check the success/failure of the publish operation.String
getId()
Return the id.ReturnedMessage
getReturned()
Get the returned message and metadata, if any.Message
getReturnedMessage()
Deprecated.in favor ofgetReturned()
.void
setId(String id)
Set the correlation id.void
setReturned(ReturnedMessage returned)
Set the returned message and metadata.void
setReturnedMessage(Message returnedMessage)
Deprecated.in favor ofsetReturned(ReturnedMessage)
.String
toString()
-
-
-
Method Detail
-
getId
public String getId()
Return the id.- Returns:
- the id.
-
setId
public void setId(String id)
Set the correlation id. Generally, the correlation id shouldn't be changed. One use case, however, is when it needs to be set in aMessagePostProcessor
.- Parameters:
id
- the id.- Since:
- 1.6
-
getFuture
public SettableListenableFuture<CorrelationData.Confirm> getFuture()
Return a future to check the success/failure of the publish operation.- Returns:
- the future.
- Since:
- 2.1
-
getReturnedMessage
@Deprecated @Nullable public Message getReturnedMessage()
Deprecated.in favor ofgetReturned()
.Return a returned message, if any; requires a uniqueid
. Guaranteed to be populated before the future is set.- Returns:
- the message or null.
- Since:
- 2.1
-
setReturnedMessage
@Deprecated public void setReturnedMessage(Message returnedMessage)
Deprecated.in favor ofsetReturned(ReturnedMessage)
.Set a returned message for this correlation data.- Parameters:
returnedMessage
- the returned message.- Since:
- 1.7.13
-
getReturned
@Nullable public ReturnedMessage getReturned()
Get the returned message and metadata, if any. Guaranteed to be populated before the future is set.- Returns:
- the
ReturnedMessage
. - Since:
- 2.3.3
-
setReturned
public void setReturned(ReturnedMessage returned)
Set the returned message and metadata.- Parameters:
returned
- theReturnedMessage
.- Since:
- 2.3.3
-
-