File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed
main/java/com/amazon/sqs/javamessaging
test/java/com/amazon/sqs/javamessaging Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,7 @@ protected jakarta.jms.Message convertToJMSMessage(Message message) throws JMSExc
382382 }
383383
384384 jmsMessage .setJMSTimestamp (getJMSTimestamp (message ));
385+ jmsMessage .setJMSDeliveryTime (getApproximateFirstReceiveTimestamp (message ));
385386 return jmsMessage ;
386387 }
387388
@@ -395,6 +396,16 @@ private long getJMSTimestamp(Message message) {
395396 }
396397 }
397398
399+ private long getApproximateFirstReceiveTimestamp (Message message ) {
400+ Map <String , String > systemAttributes = message .attributesAsStrings ();
401+ String timestamp = systemAttributes .get (SQSMessagingClientConstants .APPROXIMATE_FIRST_RECEIVE_TIMESTAMP );
402+ if (timestamp != null ) {
403+ return Long .parseLong (timestamp );
404+ } else {
405+ return 0L ;
406+ }
407+ }
408+
398409 protected void nackQueueMessages () {
399410 // Also nack messages already in the messageQueue
400411 synchronized (stateLock ) {
Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ public class SQSMessagingClientConstants {
8080
8181 public static final String SEQUENCE_NUMBER = "SequenceNumber" ;
8282
83+ public static final String APPROXIMATE_FIRST_RECEIVE_TIMESTAMP = "ApproximateFirstReceiveTimestamp" ;
84+
8385 static final String APPENDED_USER_AGENT_HEADER_VERSION ;
8486 static {
8587 try {
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ public class SQSMessage implements Message {
104104 private String type ;
105105 private SQSQueueDestination replyTo ;
106106 private Destination destination ;
107+ private long deliveryTime ;
107108
108109 private final Map <String , JMSMessagePropertyValue > properties = new HashMap <>();
109110
@@ -422,13 +423,12 @@ public void setJMSExpiration(long expiration) throws JMSException {
422423
423424 @ Override
424425 public long getJMSDeliveryTime () throws JMSException {
425- // FIXME
426- return 0 ;
426+ return deliveryTime ;
427427 }
428428
429429 @ Override
430430 public void setJMSDeliveryTime (long deliveryTime ) throws JMSException {
431- // FIXME
431+ this . deliveryTime = deliveryTime ;
432432 }
433433
434434 @ Override
Original file line number Diff line number Diff line change @@ -1830,7 +1830,7 @@ public void testRequestedMessageTracking(int numberOfMessagesToPrefetch) throws
18301830
18311831 // Wait to make sure the received calls have gotten far enough to
18321832 // wait on the message queue
1833- allReceivesWaiting .await ();
1833+ allReceivesWaiting .await (2000 , TimeUnit . MILLISECONDS );
18341834
18351835 assertEquals (concurrentReceives , consumerPrefetch .messagesRequested );
18361836
You can’t perform that action at this time.
0 commit comments