List Of Message Attributes Name Required While Sending Message Through Amazon SQS To Populate JMS Headers.

0

Hi,

We have formed a proof of concept that utilizes the libraries mentioned below. Using this we are receiving the message sent through Amazon SQS.

  1. Amazon SQS Library (com.amazon.sqs.javamessaging.message.SQSTextMessage): This library is used for Amazon Simple Queue Service (SQS) messaging. It provides classes and utilities for working with SQS messages.
  2. JMS Libraries (javax.jms): The javax.jms package contains classes and interfaces for Java Message Service (JMS), an API for working with messaging systems.

Using these libraries we are listening to the message sent through Amazon SQS. So, we are successfully able to receive the message and read it too. We are using the javax.jms.MessageListener which provides us with onMessage method which excepts an argument of type javax.jms.Message. This argument of type Message holds various headers like correlationID, expiration, messageID, type, replyTo, destination, timestamp etc. But, a few JMS headers are not getting populated which are listed below

  1. correlationID
  2. type
  3. replyTo

and a few which are mentioned below are getting populated with their default value

  1. timestamp
  2. expiration

So, while following various documents found that to get these headers populated we have to add them as the message attribute while sending the message through Amazon SQS. While digging deep I found that if we have to provide a message attribute with the name JMS_SQSCorrelationID exactly as it is to populate the field correlationID within the Message type object received by the onMessage method.

I want to know the specific message attribute name required to populate fields type, replyTo, timestamp and expiration within the Message type object received by the onMessage method. Also, I want to know how we can override the values of fields expiration, and timestamp while sending the message as currently this value is being set to the default value which is "0".

Pushkar
asked 8 months ago453 views
1 Answer
0

Hi,

Thanks for reaching out. I hope that you are doing well. We have documentation on Working with JMS and Amazon SQS. I am adding it here for reference but I assume that you have seen this already.

We can see the headers that SQS sets here in this page of that documentation

From the above documentation, SQS does not provide a header for some of the attributes you are looking for such as expiration or timestamp.

If there are any attributes that need to be sent apart from this then they would indeed need to be added as a message attribute

Message attributes are custom and optional. It will be up to the sender of the message to add the required attribute when sending a message. However, SQS does not have visibility on how a library may read these message attributes. You would need to reach out to the developer of the JMS Libraries to determine what the attribute name needs to be in order for this library to be able to automatically map this attribute such as 'JMS_SQSCorrelationID'.

Kindly note I am not familiar with the JMS library itself but I would recommend checking how to parse the SQS message attributes in order to look for your required values.

AWS
SUPPORT ENGINEER
Ryan_A
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions