You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by FabianChanton <fa...@gmx.ch> on 2016/02/25 11:24:53 UTC

RabbitMQ: Declare queue on existing exchange

Hi!

We are using Camel CDI 1.2.0, Camel core 2.16.1 and Camel RabbitMQ 2.16.1 in
our project.

For this project, I need to declare a queue on the default exchange of an
existing RabbitMQ Server. If i set declare=true on my endpoint URI the
RabbitMQConsumer tries to declare the queue and the default exchange, which
already exists. The server then replies, that I am not allowed to declare
the default exchange.

Is there a possibility to declare a queue on an existing exchange?

Best Regards

Fabian Chanton



--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah we love contributions, you are welcome to log a JIRA and work on
a patch / PR.
http://camel.apache.org/contributing

On Mon, Apr 4, 2016 at 2:21 PM, FabianChanton <fa...@gmx.ch> wrote:
> I solved this problem by making a few changes to camel-rabbitMQ.
>
> These are the parts that cause the problem:
>
> - If the consumer declares a queue it always declares the exchange as well.
> I now check, if the exchange name is null or empty and in that case don't
> declare the exchange. Maybe an option similar to "skipQueueDeclare" would be
> a good idea
>
> - If the name of the queue to be declared is not specified, the consumer
> generates a random name. In my use case the server does not allow access to
> such random names. It is necessary to declare the queue without a name. The
> server then generates a name and grants the user access to it.
>
> At the moment this solves the problem for me but it would be nice, if
> camel-rabbitMQ could be configured in such a way to support my usecase.
>
> Best regards
>
> Fabian Chanton
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5780417.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: RabbitMQ: Declare queue on existing exchange

Posted by FabianChanton <fa...@gmx.ch>.
I solved this problem by making a few changes to camel-rabbitMQ.

These are the parts that cause the problem:

- If the consumer declares a queue it always declares the exchange as well.
I now check, if the exchange name is null or empty and in that case don't
declare the exchange. Maybe an option similar to "skipQueueDeclare" would be
a good idea

- If the name of the queue to be declared is not specified, the consumer
generates a random name. In my use case the server does not allow access to
such random names. It is necessary to declare the queue without a name. The
server then generates a name and grants the user access to it. 

At the moment this solves the problem for me but it would be nice, if
camel-rabbitMQ could be configured in such a way to support my usecase.

Best regards

Fabian Chanton




--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5780417.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by souciance <so...@gmail.com>.
I will try this myself later and let you know.

On Thu, Feb 25, 2016 at 2:05 PM, FabianChanton [via Camel]
<ml...@n5.nabble.com> wrote:
> I forgot to write that I only need to read from that queue.
>
> The server side requires each client to declare a queue on the default
> exchange to receive messages. To send messages the client uses pre-declared
> queues and exchanges (this side works well, like you said).
>
> So my problem only exists when trying to declare a new queue on the default
> exchange via RabbitMQ consumer.
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778275.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here.
> NAML




--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778276.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by FabianChanton <fa...@gmx.ch>.
I forgot to write that I only need to read from that queue. 

The server side requires each client to declare a queue on the default
exchange to receive messages. To send messages the client uses pre-declared
queues and exchanges (this side works well, like you said). 

So my problem only exists when trying to declare a new queue on the default
exchange via RabbitMQ consumer.



--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778275.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by souciance <so...@gmail.com>.
That is strange because I write messages to queues on exchanges where
both are already declared and that works.

On Thu, Feb 25, 2016 at 1:43 PM, FabianChanton [via Camel]
<ml...@n5.nabble.com> wrote:
> I tried what I described without camel, by directly using the RabbitMQ Java
> Client. By directly using the client I am able to declare a queue on the
> default exchange.
>
> It seems the problem lies in the method declareExchangeAndQueue of the
> RabbitMQEndpoint. This method calls  channel.exchangeDeclare(...) if declare
> is true. It does not check if the exchange already exists or if it is the
> default exchange.
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778273.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here.
> NAML




--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778274.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by FabianChanton <fa...@gmx.ch>.
I tried what I described without camel, by directly using the RabbitMQ Java
Client. By directly using the client I am able to declare a queue on the
default exchange.

It seems the problem lies in the method declareExchangeAndQueue of the
RabbitMQEndpoint. This method calls  channel.exchangeDeclare(...) if declare
is true. It does not check if the exchange already exists or if it is the
default exchange.



--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778273.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by souciance <so...@gmail.com>.
Also, to be sure, is the default exchange and other exchanges on the same vhost?

On Thu, Feb 25, 2016 at 1:36 PM, Souciance Eqdam Rashti
<so...@gmail.com> wrote:
> Are you sure you have access to declare the queue on the default
> exchange? You can use the same user/password and login to the Rabbit
> webgui and perform the same operation manually to verify.
>
> I think it should work because I don't think endpoint declares the
> exchange as well as just "/" means revert to the default exchange
> which exist by default so it shouldn't have to declare that.
>
> On Thu, Feb 25, 2016 at 1:19 PM, FabianChanton [via Camel]
> <ml...@n5.nabble.com> wrote:
>> Hello Souciance
>>
>> Thanks for your answer!
>>
>> The standard case you described works well for me.
>>
>> However the following does not work:
>>
>> I create an endpoint with the following URI:
>>
>> rabbitmq://<host>:<port>/
>>
>> (leaving the exchange part empty because i need to declare the queue on the
>> default exchange)
>>
>> This causes the following response from the server:
>>
>> reply-text=ACCESS_REFUSED - operation not permitted on the default exchange
>>
>> I guess this is because the RabbitMQ endpoint declares the queue AND
>> exchange, but the default exchange is already present on the server.
>>
>> If I try "declare=false" it doesn't work either because the Endpoint assumes
>> a random queue ID and that  queue doesn't exist (because we don't declare
>> it)
>>
>> I saw that there is an option "skipQueueDeclare" which would only declare
>> the exchange but not the queue. What i am looking for is the opposite:
>> declare the queue but not the exchange. Something similar to the
>> exchangeDeclarePassive method of the com.rabbitmq.client.channel class.
>>
>> Best Regards
>>
>> Fabian
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778270.html
>> To start a new topic under Camel - Users, email
>> ml-node+s465427n465428h31@n5.nabble.com
>> To unsubscribe from Camel - Users, click here.
>> NAML




--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778272.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by souciance <so...@gmail.com>.
Are you sure you have access to declare the queue on the default
exchange? You can use the same user/password and login to the Rabbit
webgui and perform the same operation manually to verify.

I think it should work because I don't think endpoint declares the
exchange as well as just "/" means revert to the default exchange
which exist by default so it shouldn't have to declare that.

On Thu, Feb 25, 2016 at 1:19 PM, FabianChanton [via Camel]
<ml...@n5.nabble.com> wrote:
> Hello Souciance
>
> Thanks for your answer!
>
> The standard case you described works well for me.
>
> However the following does not work:
>
> I create an endpoint with the following URI:
>
> rabbitmq://<host>:<port>/
>
> (leaving the exchange part empty because i need to declare the queue on the
> default exchange)
>
> This causes the following response from the server:
>
> reply-text=ACCESS_REFUSED - operation not permitted on the default exchange
>
> I guess this is because the RabbitMQ endpoint declares the queue AND
> exchange, but the default exchange is already present on the server.
>
> If I try "declare=false" it doesn't work either because the Endpoint assumes
> a random queue ID and that  queue doesn't exist (because we don't declare
> it)
>
> I saw that there is an option "skipQueueDeclare" which would only declare
> the exchange but not the queue. What i am looking for is the opposite:
> declare the queue but not the exchange. Something similar to the
> exchangeDeclarePassive method of the com.rabbitmq.client.channel class.
>
> Best Regards
>
> Fabian
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778270.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here.
> NAML




--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778271.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by FabianChanton <fa...@gmx.ch>.
Hello Souciance

Thanks for your answer!

The standard case you described works well for me.

However the following does not work:

I create an endpoint with the following URI:

rabbitmq://<host>:<port>/

(leaving the exchange part empty because i need to declare the queue on the
default exchange)

This causes the following response from the server:

reply-text=ACCESS_REFUSED - operation not permitted on the default exchange

I guess this is because the RabbitMQ endpoint declares the queue AND
exchange, but the default exchange is already present on the server.

If I try "declare=false" it doesn't work either because the Endpoint assumes
a random queue ID and that  queue doesn't exist (because we don't declare
it)

I saw that there is an option "skipQueueDeclare" which would only declare
the exchange but not the queue. What i am looking for is the opposite:
declare the queue but not the exchange. Something similar to the
exchangeDeclarePassive method of the com.rabbitmq.client.channel class.

Best Regards

Fabian



--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778270.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RabbitMQ: Declare queue on existing exchange

Posted by souciance <so...@gmail.com>.
Hello Fabian

This is how the standard rabbit URI looks. rabbitmq://<host>:<port>/<exchange>

Write in any exchange that you want and it will declare the queue on
that exchange.

Best Souciance

On Thu, Feb 25, 2016 at 11:24 AM, FabianChanton [via Camel]
<ml...@n5.nabble.com> wrote:
> Hi!
>
> We are using Camel CDI 1.2.0, Camel core 2.16.1 and Camel RabbitMQ 2.16.1 in
> our project.
>
> For this project, I need to declare a queue on the default exchange of an
> existing RabbitMQ Server. If i set declare=true on my endpoint URI the
> RabbitMQConsumer tries to declare the queue and the default exchange, which
> already exists. The server then replies, that I am not allowed to declare
> the default exchange.
>
> Is there a possibility to declare a queue on an existing exchange?
>
> Best Regards
>
> Fabian Chanton
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here.
> NAML




--
View this message in context: http://camel.465427.n5.nabble.com/RabbitMQ-Declare-queue-on-existing-exchange-tp5778263p5778267.html
Sent from the Camel - Users mailing list archive at Nabble.com.