1

data types of headersI am trying to send a message directly to Exchange using the REST endpoint:

/api/exchanges/vhost/name/publish

The sample payload I am using is:

{ 
  "properties": {
    "timestamp": 1536959503,
    "message_id": "100",
    "correlation_id": " ",
    "priority": 0,
    "delivery_mode": 2,
    "headers": {
      "counter": 0,
      "content-type": "application/xml",
      "correlation-id": " ",
      "message-id": 100,
      "message-type": "message1",
      "status": "P"
    },
    "content_type": "application/xml"
  },
  "routing_key": "p.ee.pp.rr",
  "payload": "sample",
  "payload_encoding": "string"
}

In this, the only numerical values in the headers are message-id and counter.

When I receive the message from the queue into a headers map of type <String, Object>, the data type for the numerical values is Long.

My code casts message-id to long and counter to Integer. I get a class cast exception when doing the latter.

I am interested in knowing:

  1. Who is assigning the data type to the numerical values as Long? At which stage does it get assigned (in the flow of REST endpoint to the Queue)

  2. is Long the default type when reading data from JSON?

  • I see `message_id` and later `message-id` inside of `header`. Is this mis-match in names causing a problem? – EL_DON Sep 18 '18 at 19:37
  • No....the message gets published successfully...Using debug, i tried to look at the contents of the header. The numerical values have the type Long and other data is of the type String. I am curious to know who is setting the numerical values to Long by default. and if there is any way i can change it. –  Sep 18 '18 at 22:59
  • Must be the default for integer-like types, so you don't overflow at 256 or whatever. Does replacing `100` with `int(100)` work? Or if you want float, change to `100.0`, or `"100"` for string. – EL_DON Sep 18 '18 at 23:46

0 Answers0