Reputation: 49
I have a call to an rabbitmq queue, which in return responds with a json payload.
<inSequence>
<call>
<endpoint>
<address statistics="enable" trace="enable" uri="rabbitmq:/AMQPProducerSample?rabbitmq.server.host.name=10.0.0.2&rabbitmq.server.port=5672&rabbitmq.server.virtual.host=dev&rabbitmq.server.vhost=devAuth&rabbitmq.queue.name=hello&rabbitmq.queue.durable=false&rabbitmq.queue.auto.ack=true&rabbitmq.queue.exclusive=false&rabbitmq.replyto.name=false">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</call>
<header name="Content-Type" scope="transport" value="application/json"/>
<respond description="respond whatever"/>
</inSequence>
But when the answer from the queue return, console shows: [2020-10-19 19:20:39,741] WARN {RabbitMQUtils} - Unable to determine content type for message urn:uuid:88BF095D7137B387921603153239744 setting to text/plain
and it adds "text" to my already json payload: {"text":"{"jwt":"5f8e2d21c2184","error":false}"}
How do I set the answer from the rabbitmq to json or do I need to tansform that answer? because it get all strip protected.
Upvotes: 0
Views: 179
Reputation: 49
The type of the answer, is set by the endpoint as an attribute to the message, as stated by de rabbitmq documentation: https://www.rabbitmq.com/consumers.html#message-properties In case of the php rabbitmq library add 'content_type'=>'application_json' to property array of the message.
Upvotes: 0
Reputation: 473
Please try the following Synapse artifact.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="RabbitMQRPCProxy"
startOnLoad="true"
trace="enable"
transports="http">
<description/>
<target>
<inSequence>
<log level="full">
<property name="received" value="true"/>
</log>
<call>
<endpoint>
<address uri="rabbitmq://?rabbitmq.server.host.name=localhost&rabbitmq.server.port=5672&rabbitmq.server.user.name=guest&rabbitmq.server.password=guest&rabbitmq.queue.name=rpc_queue&rabbitmq.queue.routing.key=rpc_queue&rabbitmq.replyto.name=dummy"/>
</endpoint>
</call>
<log level="full">
<property name="response" value="true"/>
</log>
<respond/>
</inSequence>
<outSequence/>
</target>
</proxy>
Here,
For more detail, have a look RabbitMQ listener and sender documentation.
Upvotes: 0