What is JMSType used for? Can it be used to define the message payload? For example, the payload might be for adding a product and the JMSType could be AddProduct.
JMS Specification says "The JMSType
header field contains a message type identifier supplied by a
client when a message is sent. Some JMS providers use a message repository that contains the definitions of messages sent by applications. The type header field may reference a message’s
definition in the provider’s repository. JMS does not define a standard message definition repository, nor does it define a naming policy for the definitions it contains."
In effect, you can set JMSType
to a value of your choice but it is suggested you make sure every application that runs on your JMS provider use the same values for JMSType
.
The specification is still a bit vague about what type
exactly means, so let's quote from O'Reilly for additional context:
JMSType — Purpose: Identification.
JMSType is an optional header set by the JMS client. Its name is somewhat misleading because it has nothing to do with the type of message being sent (BytesMessage, MapMessage, etc.). Its main purpose is to identify the message structure and type of payload; it is only supported by a couple of vendors.
Thus to answer your question, you are right to assume you can add AddProduct
as JMSType key. Your code could look something like:
jmsClient.sendToTopic(SOME_TOPIC, session -> {
var message = session.createTextMessage("{\"name\":\"Ikea MITTZON desk\"}");
message.setJMSType("AddProduct");
return message;
});
© 2022 - 2024 — McMap. All rights reserved.