Skip to content

Commit

Permalink
DelayHandler: Improve Instant handling
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan committed Jul 12, 2022
1 parent f349e1a commit cd6b0c5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.integration.handler;

import java.io.Serial;
import java.io.Serializable;
import java.time.Instant;
import java.util.Collection;
Expand Down Expand Up @@ -418,7 +419,7 @@ private void releaseMessageAfterDelay(final Message<?> message, long delay) {
messageWrapper = (DelayedMessageWrapper) message.getPayload();
}
else {
messageWrapper = new DelayedMessageWrapper(message, System.currentTimeMillis());
messageWrapper = new DelayedMessageWrapper(message, Instant.now().toEpochMilli());
delayedMessage = getMessageBuilderFactory()
.withPayload(messageWrapper)
.copyHeaders(message.getHeaders())
Expand All @@ -427,7 +428,7 @@ private void releaseMessageAfterDelay(final Message<?> message, long delay) {
}

Runnable releaseTask = releaseTaskForMessage(delayedMessage);
Instant startTime = Instant.ofEpochMilli(messageWrapper.getRequestDate() + delay);
Instant startTime = Instant.ofEpochMilli(messageWrapper.getRequestDate()).plusMillis(delay);

if (TransactionSynchronizationManager.isSynchronizationActive() &&
TransactionSynchronizationManager.isActualTransactionActive()) {
Expand Down Expand Up @@ -637,6 +638,7 @@ public void handleMessage(Message<?> message) throws MessagingException {

public static final class DelayedMessageWrapper implements Serializable {

@Serial
private static final long serialVersionUID = -4739802369074947045L;

private final long requestDate;
Expand Down

0 comments on commit cd6b0c5

Please sign in to comment.