You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by mARK bLOORE <mb...@gmail.com> on 2009/09/29 23:19:15 UTC

can't config a fanout exchange

With this in my virtualhosts.xml file
            <exchanges>
                <exchange>
                    <type>fanout</type>
                    <name>test-exchange</name>
                    <durable>true</durable>
                </exchange>
            <.exchanges>

When I try to declare test-exchange to be fanout I get

'Attempt to redeclare exchange: test-exchange of type direct to
fanout. [error code 530: not allowed]'

Without that config things work fine, but the exchange does not exist
at startup.

What am I doing wrong?

-- 
mARK bLOORE <mb...@gmail.com>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


RE: can't config a fanout exchange

Posted by Robbie Gemmell <ro...@gmail.com>.
Just to revive this ancient thread... :-)

I have run into a similar issue recently relating to exchange durability and
found that the code responsible for parsing the exchange configuration isn't
fully able to handle the configuration being placed in the virtualhosts.xml
file. It does however seem to work as expected when the configuration is
placed in the main config.xml file. I believe the same will be true of your
issue below. The imminent 0.6 release will be similarly affected, although
the shipping config is all contained in config.xml for now as luck would
have it.

Robbie

> -----Original Message-----
> From: mARK bLOORE [mailto:mbloore@gmail.com]
> Sent: 29 September 2009 22:19
> To: users@qpid.apache.org
> Subject: can't config a fanout exchange
> 
> With this in my virtualhosts.xml file
>             <exchanges>
>                 <exchange>
>                     <type>fanout</type>
>                     <name>test-exchange</name>
>                     <durable>true</durable>
>                 </exchange>
>             <.exchanges>
> 
> When I try to declare test-exchange to be fanout I get
> 
> 'Attempt to redeclare exchange: test-exchange of type direct to
> fanout. [error code 530: not allowed]'
> 
> Without that config things work fine, but the exchange does not exist
> at startup.
> 
> What am I doing wrong?
> 
> --
> mARK bLOORE <mb...@gmail.com>
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: can't config a fanout exchange

Posted by Robert Godfrey <ro...@gmail.com>.
OK - that'll teach me to try to diagnose problems past 2am while using
netbook with a screen the size of a postage stamp :-)

Not had a chance yet today to play with the code - been unexpectedly busy
with other things... however from the code snipped below...
I'm tending to the view that the whole thing just needs to be fixed
properly... Changing the Java Broker code in VirtualHostConfiguration be the
similar to queue (which would be consistent) would hopefully mean that the
way I suggested of configuring it would work...  I've no idea what the
current code is supposed to do - but it clearly doesn't work :-(

Apologies,
Rob



2009/9/30 mARK bLOORE <mb...@gmail.com>

> Thanks, Rob.  That syntax is more consistent with the rest of the
> config style, though it strikes me as odd.  Unfortunately, it produces
> the same error.
>
> But I wonder about the syntax.  In
> org/apache/qpid/server/configuration/VirtualHostConfiguration.java,
> where queues get added to the configuration with
>   mungedConf.addConfiguration(_config.subset("queues.queue." + queueName));
> exchanges get added with
>   mungedConf.addConfiguration(config.subset("exchanges.exchange(" +
> count++ + ")"));
> which looks like they are indexed rather than named, and so the config
> data is one level shallower.  Why they should be different I can't
> guess, and I haven't figured out how to use this fact.
>
>
> On Tue, Sep 29, 2009 at 8:19 PM, Robert Godfrey <ro...@gmail.com>
> wrote:
> > And a little more digging....
> >
> > Looking at how the code interprets the configuration file, versus how the
> > example is used in virtualhosts.xml ... it appears to me as if the
> example
> > in our release is wrong
> >
> > I *think* that instead of looking like
> >
> > <exchange>
> >    <name>test</name>
> >    <type>fanout</type>
> >    <durable>true</durable>
> > </exchange>
> >
> > instead it should be specified as
> >
> > <exchange>
> >    <name>test</name>
> >    <test>   <!-- use tag with the same name as the exchange you are
> > defining -->
> >        <type>fanout</type>
> >        <durable>true</durable>
> >    </test>
> > </exchange>
> >
> > There is some code that says that if it doesn't find a configuration,
> > default to direct as the type....
> >
> > I shall test this tomorrow when I'm back using a computer that's actually
> > capable of running the broker
> >
> > Apologies,
> > Rob
> >
> > 2009/9/30 Robert Godfrey <ro...@gmail.com>
> >
> >> Hi Mark,
> >>
> >> 2009/9/30 mARK bLOORE <mb...@gmail.com>
> >>
> >>> Thanks for the reply, Rob, but actually I set the exchange to fanout
> >>> in the config file, and declared it to be fanout in my code, but the
> >>> broker seems to think it was configured as direct.
> >>>
> >>> If I don't configure it the code runs fine, but I would rather have it
> >>> already exist, so that I can publish to it without having to ensure
> >>> that a queue is bound to it first.
> >>>
> >>>
> >>>
> >> My apologies, I read the error message in haste.... and must have
> mentally
> >> swapped the order of "fanout" and "direct"
> >>
> >> The error code from the Java Broker says
> >>
> >> 'Attempt to redeclare exchange: test-exchange of type direct to
> >> fanout. [error code 530: not allowed]'
> >>
> >> This is generated by the following code inside the Java Broker:
> >>
> >> else if (!exchange.getType().equals(body.getType()))
> >>             {
> >>
> >>                 throw new
> AMQConnectionException(AMQConstant.NOT_ALLOWED,
> >> "Attempt to redeclare exchange: " + body.getExchange() + " of type " +
> >> exchange.getType() + " to " + body.getType() +".",body.getClazz(),
> >> body.getMethod(),body.getMajor(),body.getMinor(),null);
> >>             }
> >>
> >> So it appears that the config is creating a direct exchange and not a
> >> fanout exchange as you would expect...
> >>
> >> I'm presuming that your config:
> >>
> >>            <exchanges>
> >>                <exchange>
> >>                    <type>fanout</type>
> >>                    <name>test-exchange</name>
> >>                    <durable>true</durable>
> >>                </exchange>
> >>            <.exchanges>
> >>
> >> is not a completely accurate cut and paste (i.e. the last line is
> actually
> >> </exchanges> in the config file?)
> >>
> >> However looking at the current codebase I can see no reason why an
> exchange
> >> declared in the config would be created as direct... Can you confirm
> which
> >> release of the broker you are using?
> >>
> >> Thanks,
> >> Rob
> >>
> >>
> >>
> >>
> >>
> >
>
>
>
> --
> mARK bLOORE <mb...@gmail.com>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>

Re: can't config a fanout exchange

Posted by mARK bLOORE <mb...@gmail.com>.
Thanks, Rob.  That syntax is more consistent with the rest of the
config style, though it strikes me as odd.  Unfortunately, it produces
the same error.

But I wonder about the syntax.  In
org/apache/qpid/server/configuration/VirtualHostConfiguration.java,
where queues get added to the configuration with
   mungedConf.addConfiguration(_config.subset("queues.queue." + queueName));
exchanges get added with
   mungedConf.addConfiguration(config.subset("exchanges.exchange(" +
count++ + ")"));
which looks like they are indexed rather than named, and so the config
data is one level shallower.  Why they should be different I can't
guess, and I haven't figured out how to use this fact.


On Tue, Sep 29, 2009 at 8:19 PM, Robert Godfrey <ro...@gmail.com> wrote:
> And a little more digging....
>
> Looking at how the code interprets the configuration file, versus how the
> example is used in virtualhosts.xml ... it appears to me as if the example
> in our release is wrong
>
> I *think* that instead of looking like
>
> <exchange>
>    <name>test</name>
>    <type>fanout</type>
>    <durable>true</durable>
> </exchange>
>
> instead it should be specified as
>
> <exchange>
>    <name>test</name>
>    <test>   <!-- use tag with the same name as the exchange you are
> defining -->
>        <type>fanout</type>
>        <durable>true</durable>
>    </test>
> </exchange>
>
> There is some code that says that if it doesn't find a configuration,
> default to direct as the type....
>
> I shall test this tomorrow when I'm back using a computer that's actually
> capable of running the broker
>
> Apologies,
> Rob
>
> 2009/9/30 Robert Godfrey <ro...@gmail.com>
>
>> Hi Mark,
>>
>> 2009/9/30 mARK bLOORE <mb...@gmail.com>
>>
>>> Thanks for the reply, Rob, but actually I set the exchange to fanout
>>> in the config file, and declared it to be fanout in my code, but the
>>> broker seems to think it was configured as direct.
>>>
>>> If I don't configure it the code runs fine, but I would rather have it
>>> already exist, so that I can publish to it without having to ensure
>>> that a queue is bound to it first.
>>>
>>>
>>>
>> My apologies, I read the error message in haste.... and must have mentally
>> swapped the order of "fanout" and "direct"
>>
>> The error code from the Java Broker says
>>
>> 'Attempt to redeclare exchange: test-exchange of type direct to
>> fanout. [error code 530: not allowed]'
>>
>> This is generated by the following code inside the Java Broker:
>>
>> else if (!exchange.getType().equals(body.getType()))
>>             {
>>
>>                 throw new AMQConnectionException(AMQConstant.NOT_ALLOWED,
>> "Attempt to redeclare exchange: " + body.getExchange() + " of type " +
>> exchange.getType() + " to " + body.getType() +".",body.getClazz(),
>> body.getMethod(),body.getMajor(),body.getMinor(),null);
>>             }
>>
>> So it appears that the config is creating a direct exchange and not a
>> fanout exchange as you would expect...
>>
>> I'm presuming that your config:
>>
>>            <exchanges>
>>                <exchange>
>>                    <type>fanout</type>
>>                    <name>test-exchange</name>
>>                    <durable>true</durable>
>>                </exchange>
>>            <.exchanges>
>>
>> is not a completely accurate cut and paste (i.e. the last line is actually
>> </exchanges> in the config file?)
>>
>> However looking at the current codebase I can see no reason why an exchange
>> declared in the config would be created as direct... Can you confirm which
>> release of the broker you are using?
>>
>> Thanks,
>> Rob
>>
>>
>>
>>
>>
>



-- 
mARK bLOORE <mb...@gmail.com>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: can't config a fanout exchange

Posted by Robert Godfrey <ro...@gmail.com>.
And a little more digging....

Looking at how the code interprets the configuration file, versus how the
example is used in virtualhosts.xml ... it appears to me as if the example
in our release is wrong

I *think* that instead of looking like

<exchange>
    <name>test</name>
    <type>fanout</type>
    <durable>true</durable>
</exchange>

instead it should be specified as

<exchange>
    <name>test</name>
    <test>   <!-- use tag with the same name as the exchange you are
defining -->
        <type>fanout</type>
        <durable>true</durable>
    </test>
</exchange>

There is some code that says that if it doesn't find a configuration,
default to direct as the type....

I shall test this tomorrow when I'm back using a computer that's actually
capable of running the broker

Apologies,
Rob

2009/9/30 Robert Godfrey <ro...@gmail.com>

> Hi Mark,
>
> 2009/9/30 mARK bLOORE <mb...@gmail.com>
>
>> Thanks for the reply, Rob, but actually I set the exchange to fanout
>> in the config file, and declared it to be fanout in my code, but the
>> broker seems to think it was configured as direct.
>>
>> If I don't configure it the code runs fine, but I would rather have it
>> already exist, so that I can publish to it without having to ensure
>> that a queue is bound to it first.
>>
>>
>>
> My apologies, I read the error message in haste.... and must have mentally
> swapped the order of "fanout" and "direct"
>
> The error code from the Java Broker says
>
> 'Attempt to redeclare exchange: test-exchange of type direct to
> fanout. [error code 530: not allowed]'
>
> This is generated by the following code inside the Java Broker:
>
> else if (!exchange.getType().equals(body.getType()))
>             {
>
>                 throw new AMQConnectionException(AMQConstant.NOT_ALLOWED,
> "Attempt to redeclare exchange: " + body.getExchange() + " of type " +
> exchange.getType() + " to " + body.getType() +".",body.getClazz(),
> body.getMethod(),body.getMajor(),body.getMinor(),null);
>             }
>
> So it appears that the config is creating a direct exchange and not a
> fanout exchange as you would expect...
>
> I'm presuming that your config:
>
>            <exchanges>
>                <exchange>
>                    <type>fanout</type>
>                    <name>test-exchange</name>
>                    <durable>true</durable>
>                </exchange>
>            <.exchanges>
>
> is not a completely accurate cut and paste (i.e. the last line is actually
> </exchanges> in the config file?)
>
> However looking at the current codebase I can see no reason why an exchange
> declared in the config would be created as direct... Can you confirm which
> release of the broker you are using?
>
> Thanks,
> Rob
>
>
>
>
>

Re: can't config a fanout exchange

Posted by Robert Godfrey <ro...@gmail.com>.
Hi Mark,

2009/9/30 mARK bLOORE <mb...@gmail.com>

> Thanks for the reply, Rob, but actually I set the exchange to fanout
> in the config file, and declared it to be fanout in my code, but the
> broker seems to think it was configured as direct.
>
> If I don't configure it the code runs fine, but I would rather have it
> already exist, so that I can publish to it without having to ensure
> that a queue is bound to it first.
>
>
>
My apologies, I read the error message in haste.... and must have mentally
swapped the order of "fanout" and "direct"

The error code from the Java Broker says

'Attempt to redeclare exchange: test-exchange of type direct to
fanout. [error code 530: not allowed]'

This is generated by the following code inside the Java Broker:

else if (!exchange.getType().equals(body.getType()))
            {

                throw new AMQConnectionException(AMQConstant.NOT_ALLOWED,
"Attempt to redeclare exchange: " + body.getExchange() + " of type " +
exchange.getType() + " to " + body.getType() +".",body.getClazz(),
body.getMethod(),body.getMajor(),body.getMinor(),null);
            }

So it appears that the config is creating a direct exchange and not a fanout
exchange as you would expect...

I'm presuming that your config:

           <exchanges>
               <exchange>
                   <type>fanout</type>
                   <name>test-exchange</name>
                   <durable>true</durable>
               </exchange>
           <.exchanges>

is not a completely accurate cut and paste (i.e. the last line is actually
</exchanges> in the config file?)

However looking at the current codebase I can see no reason why an exchange
declared in the config would be created as direct... Can you confirm which
release of the broker you are using?

Thanks,
Rob

Re: can't config a fanout exchange

Posted by mARK bLOORE <mb...@gmail.com>.
Thanks for the reply, Rob, but actually I set the exchange to fanout
in the config file, and declared it to be fanout in my code, but the
broker seems to think it was configured as direct.

If I don't configure it the code runs fine, but I would rather have it
already exist, so that I can publish to it without having to ensure
that a queue is bound to it first.

On Tue, Sep 29, 2009 at 5:39 PM, Robert Godfrey <ro...@gmail.com> wrote:
> 2009/9/29 mARK bLOORE <mb...@gmail.com>
>
>> With this in my virtualhosts.xml file
>>            <exchanges>
>>                <exchange>
>>                    <type>fanout</type>
>>                    <name>test-exchange</name>
>>                    <durable>true</durable>
>>                </exchange>
>>            <.exchanges>
>>
>> When I try to declare test-exchange to be fanout I get
>>
>> 'Attempt to redeclare exchange: test-exchange of type direct to
>> fanout. [error code 530: not allowed]'
>>
>> Without that config things work fine, but the exchange does not exist
>> at startup.
>>
>> What am I doing wrong?
>>
>>
> The error code indicates that you are trying to declare the exchange as a
> "direct" exchange within your application, while in the configuration you
> are declaring it as type "fanout" - the server will not let you change the
> type of an existing exchange.  You need to make sure that when you declare
> the exchange you pass in the correct type... Which client are you using
> (Python/Java etc)?
>
> Hope this helps,
> Rob
>
>
>> --
>> mARK bLOORE <mb...@gmail.com>
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>>
>



-- 
mARK bLOORE <mb...@gmail.com>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: can't config a fanout exchange

Posted by Robert Godfrey <ro...@gmail.com>.
2009/9/29 mARK bLOORE <mb...@gmail.com>

> With this in my virtualhosts.xml file
>            <exchanges>
>                <exchange>
>                    <type>fanout</type>
>                    <name>test-exchange</name>
>                    <durable>true</durable>
>                </exchange>
>            <.exchanges>
>
> When I try to declare test-exchange to be fanout I get
>
> 'Attempt to redeclare exchange: test-exchange of type direct to
> fanout. [error code 530: not allowed]'
>
> Without that config things work fine, but the exchange does not exist
> at startup.
>
> What am I doing wrong?
>
>
The error code indicates that you are trying to declare the exchange as a
"direct" exchange within your application, while in the configuration you
are declaring it as type "fanout" - the server will not let you change the
type of an existing exchange.  You need to make sure that when you declare
the exchange you pass in the correct type... Which client are you using
(Python/Java etc)?

Hope this helps,
Rob


> --
> mARK bLOORE <mb...@gmail.com>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>