Artemis: Autocreate durable queues (via AMQP)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Artemis: Autocreate durable queues (via AMQP)

andi welchlin
Hello,

I would like to use queues which are automatically created.

So I tried it out and saw that they are not durable (persistent), which
means a late joiner will not get messages.

My try to configure some default behaviour for all queues which begin with
'M' was this:

  <address name="M#">
          <anycast>
               <queue name="M#">
                   <durable>true</durable>
               </queue>
          </anycast>
  </address>


But this did not work.

Is there someone who can help me?

Kind Regards,
Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Artemis: Autocreate durable queues (via AMQP)

jbertram
Can you elaborate on your use-case a bit?  What is the client doing to
cause the queue to be auto-created (e.g. sending a message, creating a
consumer, etc.).  Is the client using the JMS API?  If so, it is working
with a "queue" or a "topic"?

Also, the "name" attributes of the address and queue elements don't support
wild-cards.  Wild-cards are supported in the "match" elements of things
like address-setting.


Justin

On Fri, Jan 5, 2018 at 10:15 AM, andi welchlin <[hidden email]>
wrote:

> Hello,
>
> I would like to use queues which are automatically created.
>
> So I tried it out and saw that they are not durable (persistent), which
> means a late joiner will not get messages.
>
> My try to configure some default behaviour for all queues which begin with
> 'M' was this:
>
>   <address name="M#">
>           <anycast>
>                <queue name="M#">
>                    <durable>true</durable>
>                </queue>
>           </anycast>
>   </address>
>
>
> But this did not work.
>
> Is there someone who can help me?
>
> Kind Regards,
> Andreas
>
Reply | Threaded
Open this post in threaded view
|

Re: Artemis: Autocreate durable queues (via AMQP)

andi welchlin
Hello Justin,

I am using the QPID Proton API (Python) and create a producer via AMQP 1.0.
I think there is no preference if it should be a queue or an exchange when
you create a producer using AMQP.

In the code it looks like:


*sender = container.create_sender(self.conn,
topic_name)sender.send(amqp_message)*

That's it.

My idea was to define some defaults in Artemis depending on the topic name
so Artemis could autocreate a queue which is persistent.

Kind Regards,
Andreas





On Fri, Jan 5, 2018 at 5:40 PM, Justin Bertram <[hidden email]> wrote:

> Can you elaborate on your use-case a bit?  What is the client doing to
> cause the queue to be auto-created (e.g. sending a message, creating a
> consumer, etc.).  Is the client using the JMS API?  If so, it is working
> with a "queue" or a "topic"?
>
> Also, the "name" attributes of the address and queue elements don't support
> wild-cards.  Wild-cards are supported in the "match" elements of things
> like address-setting.
>
>
> Justin
>
> On Fri, Jan 5, 2018 at 10:15 AM, andi welchlin <[hidden email]>
> wrote:
>
> > Hello,
> >
> > I would like to use queues which are automatically created.
> >
> > So I tried it out and saw that they are not durable (persistent), which
> > means a late joiner will not get messages.
> >
> > My try to configure some default behaviour for all queues which begin
> with
> > 'M' was this:
> >
> >   <address name="M#">
> >           <anycast>
> >                <queue name="M#">
> >                    <durable>true</durable>
> >                </queue>
> >           </anycast>
> >   </address>
> >
> >
> > But this did not work.
> >
> > Is there someone who can help me?
> >
> > Kind Regards,
> > Andreas
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Artemis: Autocreate durable queues (via AMQP)

jbertram
If a client doesn't explicitly (e.g. via the core API, by using a
configured prefix, etc.) or implicitly (e.g. working with a JMS queue (i.e.
anycast) or JMS topic (i.e. multicast)) specify a routing type then the
broker uses the defaults (which is multicast for both addresses and queues)
when auto-creating resources.  The defaults are set via the
"default-address-routing-type" and "default-queue-routing-type" elements of
"address-setting".  You can read more about this in the documentation [1].

In your case, if you are using the defaults and you send a message to an
address which doesn't exist then that address will be auto-created as
multicast (i.e. the default).  Multicast provides publish/subscribe
semantics in Artemis and the fact that the address doesn't exist means that
no subscribers care about the message you sent which means the message will
be discarded.  In other words, it will not be routed to any queues.  If you
changed the default to anycast then both an anycast address and a durable
anycast queue would be created and the message would be routed to that
anycast queue.

Please let me know if you have additional questions.


Justin

[1] https://activemq.apache.org/artemis/docs/latest/address-model.html

On Fri, Jan 5, 2018 at 11:04 AM, andi welchlin <[hidden email]>
wrote:

> Hello Justin,
>
> I am using the QPID Proton API (Python) and create a producer via AMQP 1.0.
> I think there is no preference if it should be a queue or an exchange when
> you create a producer using AMQP.
>
> In the code it looks like:
>
>
> *sender = container.create_sender(self.conn,
> topic_name)sender.send(amqp_message)*
>
> That's it.
>
> My idea was to define some defaults in Artemis depending on the topic name
> so Artemis could autocreate a queue which is persistent.
>
> Kind Regards,
> Andreas
>
>
>
>
>
> On Fri, Jan 5, 2018 at 5:40 PM, Justin Bertram <[hidden email]>
> wrote:
>
> > Can you elaborate on your use-case a bit?  What is the client doing to
> > cause the queue to be auto-created (e.g. sending a message, creating a
> > consumer, etc.).  Is the client using the JMS API?  If so, it is working
> > with a "queue" or a "topic"?
> >
> > Also, the "name" attributes of the address and queue elements don't
> support
> > wild-cards.  Wild-cards are supported in the "match" elements of things
> > like address-setting.
> >
> >
> > Justin
> >
> > On Fri, Jan 5, 2018 at 10:15 AM, andi welchlin <[hidden email]>
> > wrote:
> >
> > > Hello,
> > >
> > > I would like to use queues which are automatically created.
> > >
> > > So I tried it out and saw that they are not durable (persistent), which
> > > means a late joiner will not get messages.
> > >
> > > My try to configure some default behaviour for all queues which begin
> > with
> > > 'M' was this:
> > >
> > >   <address name="M#">
> > >           <anycast>
> > >                <queue name="M#">
> > >                    <durable>true</durable>
> > >                </queue>
> > >           </anycast>
> > >   </address>
> > >
> > >
> > > But this did not work.
> > >
> > > Is there someone who can help me?
> > >
> > > Kind Regards,
> > > Andreas
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Artemis: Autocreate durable queues (via AMQP)

AndreSteenbergen
> If a client doesn't explicitly (e.g. via the core API, by using a
> configured prefix, etc.) or implicitly (e.g. working with a JMS queue
> (i.e.
> anycast) or JMS topic (i.e. multicast)) specify a routing type then the
> broker uses the defaults (which is multicast for both addresses and
> queues)
> when auto-creating resources.  The defaults are set via the
> "default-address-routing-type" and "default-queue-routing-type" elements
> of
> "address-setting".  You can read more about this in the documentation [1].

Do you have any example configuration?
https://stackoverflow.com/questions/51389611/how-to-set-routing-type-activemq-artemis-from-client

I am trying to auto-create durable queues as well, and I can't seem to find
the way to configure it correctly to allow sending messages before
consuming.




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Artemis: Autocreate durable queues (via AMQP)

AndreSteenbergen
In reply to this post by jbertram
@Andreas:

I had the same issue. You can define the target capability ("queue").
Artemis will create a Anycast instead of Multicast. So the queue will hold
message until a consumer comes along. I have created a c# example:

public async Task TestHelloWorld()
        {
            //strange, works using regular activeMQ and the amqp test broker
from here: http://azure.github.io/amqpnetlite/articles/hello_amqp.html
            //but this does not work in ActiveMQ Artemis
            Address address = new
Address("amqp://guest:guest@localhost:5672");
            Connection connection = await
Connection.Factory.CreateAsync(address);
            Session session = new Session(connection);
           
            Message message = new Message("Hello AMQP");

            Target target = new Target
            {
                Address = "q1",
                Capabilities = new Symbol[] { new Symbol("queue") }
            };

            SenderLink sender = new SenderLink(session, "sender-link",
target, null);
            await sender.SendAsync(message);

            Source source = new Source
            {
                Address = "q1",
                Capabilities = new Symbol[] { new Symbol("queue") }
            };

            ReceiverLink receiver = new ReceiverLink(session,
"receiver-link", source, null);
            message = await receiver.ReceiveAsync();
            receiver.Accept(message);

            await sender.CloseAsync();
            await receiver.CloseAsync();
            await session.CloseAsync();
            await connection.CloseAsync();
        }



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html