Closed aparamon closed 5 years ago
This is activemq specific so not something I'd look to add -- particularly since it's easily added by the client app using a listener. Example here: https://github.com/jasonrbriggs/stomp.py/blob/master/stomp/test/misc_test.py#L15
Just in case anyone tumbles on this issue looking for answers about why your ActiveMQ is not transforming your JSON to MapMessage when you read in Java the message you sent using stomp.py (even though you’re correctly setting the transformation
header), try setting the transformation='jms-map-json'
in the send
method and auto_content_length=False
in the Connection
constructor, something like this:
import stomp
def main():
conn = stomp.Connection(('localhost', 61616,), auto_content_length=False)
conn.connect('user', 'password', wait=True)
conn.send(destination='/queue/TEST', body=to_map_json({'id': '123'}), transformations='jms-map-json')
def to_map_json(obj):
return json.dumps({'map':
{'entry':
[{'string': [str(key), str(value)]}
for key, value in obj.items()]}})
This works for me in the following environment:
Had a similar issue here however the transformations
parameter should be transformation
.
It is proposed that stomp.py supports MapMessage and ObjectMessage formats, which correspond naturally to Python
dict
and (pickleable) object structures.This can be most easily achieved by specifying header
transformation=jms-map-json
and applying the following serialization/deserialization code: