What is JMSType used for?
Asked Answered
jms
C

2

10

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.

Crabtree answered 30/8, 2014 at 2:35 Comment(0)
S
11

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.

Slr answered 1/9, 2014 at 3:30 Comment(0)
D
0

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.

Source


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;
});
Delubrum answered 7/6 at 8:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.