Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @author Artem Bilan
* @author Ngoc Nhan
* @author Johan Kaving
* @author Raul Avila
*
* @since 1.0
*/
Expand Down Expand Up @@ -147,7 +148,11 @@ else if (MessageProperties.RETRY_COUNT.equals(key)) {
if (target.getRetryCount() == 0) {
List<Map<String, ?>> xDeathHeader = target.getXDeathHeader();
if (!CollectionUtils.isEmpty(xDeathHeader)) {
target.setRetryCount((long) xDeathHeader.get(0).get("count"));
Object value = xDeathHeader.get(0).get("count");

if (value instanceof Number numberValue) {
target.setRetryCount(numberValue.longValue());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ public void testToMessagePropertiesLongStringInMap() {
assertThat(((Map<String, Object>) messageProperties.getHeaders().get("map")).get("longString")).as("LongString nested in Map not converted to String").isEqualTo(longStringString);
}

@Test
public void testToMessagePropertiesXDeathCount() {
Map<String, Object> headers = new HashMap<String, Object>();

headers.put("x-death", List.of(Map.of("count", Integer.valueOf(2))));

BasicProperties source = new BasicProperties.Builder()
.headers(headers)
.build();

MessageProperties messageProperties = messagePropertiesConverter.toMessageProperties(source, envelope, "UTF-8");

assertThat(messageProperties.getRetryCount()).isEqualTo(2);
}

@Test
public void testLongLongString() {
Map<String, Object> headers = new HashMap<String, Object>();
Expand Down