title: Is it possible to create a new RabbitMQ queue from a proxy in WSO2 ESB that previously didn’t exist?
body: <p>We are using WSO2 with RabbitMQ in our project. One requirement is that the consumer of RabbitMQ should generate the queue in case it did not previously exist. </p>
  
  <p>We make the following proxy (without creating the "queue" queue previously in the Rabbit broker):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;proxy name="AMQPProxy3" startOnLoad="true" trace="enable" transports="rabbitmq" xmlns="http://ws.apache.org/ns/synapse"&gt;
  &lt;target&gt;
      &lt;inSequence&gt;
          &lt;log level="full"/&gt;
          &lt;property name="OUT_ONLY" scope="default" type="STRING" value="true"/&gt;
          &lt;property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/&gt;
          &lt;send&gt;
              &lt;endpoint&gt;
                  &lt;address uri="http://localhost:8080/greeting"/&gt;
              &lt;/endpoint&gt;
          &lt;/send&gt;
      &lt;/inSequence&gt;
      &lt;outSequence/&gt;
      &lt;faultSequence/&gt;
  &lt;/target&gt;
  &lt;parameter name="rabbitmq.queue.name"&gt;queue&lt;/parameter&gt;
  &lt;parameter name="rabbitmq.connection.factory"&gt;AMQPConnectionFactory&lt;/parameter&gt;
  &lt;/proxy&gt;
  </code></pre>
  
  <p>The ESB throws the following exception:</p>
  
  <blockquote>
    <p>TID: [-1] [] [2017-08-25 13:23:06,139] ERROR {org.apache.axis2.transport.rabbitmq.ServiceTaskManager} -  Error, Connection already closed AMQPProxy3, Listner id - 302 {org.apache.axis2.transport.rabbitmq.ServiceTaskManager}
    com.rabbitmq.client.AlreadyClosedException: channel is already closed due to channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue 'queue' in vhost '/', class-id=50, method-id=10)</p>
  </blockquote>
  
  <p>In this case, the RabbitMQ consumer using the ESB does not create the queue in case it does not exist.</p>
  
  <p>However, if we use a Java project that uses amqp-client-4.0.2.jar (Java library that gives us the official page of Rabbit) that consumer is able to create the queue.</p>
  
  <pre><code>package com.ing.rabbitmq;
  import com.rabbitmq.client.Channel;
  import com.rabbitmq.client.Connection;
  import com.rabbitmq.client.ConnectionFactory;
  
  public class Send2 {
  
     private final static String QUEUE_NAME = "queue";
  
     public static void main(String[] argv) throws Exception {
  
     ConnectionFactory factory = new ConnectionFactory();
     factory.setHost("localhost");
     Connection connection = factory.newConnection();
     Channel channel = connection.createChannel();
  
     channel.queueDeclare(QUEUE_NAME, false, false, false, null);
     String message = "{\"id\":100,\"content\":\"Manolito\"}";
     channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
     System.out.println(" [x] Sent '" + message + "'");
  
     channel.close();
     connection.close();
    }
  }
  </code></pre>
  
  <p>Could we get the ESB to create the queue just like if we used the java client (amqp-client-4.0.2.jar)?</p>