You can follow documentation for RabbitMQ AMQP Transport here[1] if you wish to use exchange type as direct.According to the following implementation
if you don't specify the exchange type it will set to direct by default.String exchangerType = properties.get(RabbitMQConstants.EXCHANGE_TYPE);
if (exchangerType != null) {
String durable = properties.get(RabbitMQConstants.EXCHANGE_DURABLE);
if (durable != null) {
channel.exchangeDeclare(exchangeName, exchangerType, Boolean.parseBoolean(durable));
} else {
channel.exchangeDeclare(exchangeName, exchangerType, true);
}
} else {
channel.exchangeDeclare(exchangeName, "direct", true);
}
So how to use other exchange types such as topic, headers, x-consistent-hash etc...
Simple solution is to introduce the property "rabbitmq.exchange.type" to your proxy end-point URI.
Default sample proxy,
<proxy xmlns="http://ws.apache.org/ns/synapse" name="AMQPProxy" transports="rabbitmq" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <log level="full"/> <property name="OUT_ONLY" value="true"/> <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/> </inSequence> <endpoint> <address uri="rabbitmq:/AMQPProxy?rabbitmq.server.host.name=localhost&rabbitmq.server.port=5672&rabbitmq.server.user.name=guest&rabbitmq.server.password=guest&rabbitmq.queue.name=queue2&rabbitmq.exchange.name=exchange2"/> </endpoint> </target> <parameter name="rabbitmq.queue.name">queue1</parameter> <parameter name="rabbitmq.exchange.name">exchange1</parameter> <parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter> <description></description></proxy>Following is my updated end-point, which is going to use x-consistent-hash as the exchange type.
<endpoint> <address uri="rabbitmq:/AMQPProxy?rabbitmq.server.host.name=localhost&rabbitmq.server.port=5672&rabbitmq.server.user.name=guest&rabbitmq.server.password=guest&rabbitmq.queue.name=queue2&rabbitmq.exchange.type=x-consistent-hash&rabbitmq.exchange.name=exchange2"/> </endpoint>[1]. http://docs.wso2.org/display/ESB460/RabbitMQ+AMQP+Transport
No comments:
Post a Comment