You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Michael Ivanov <iv...@logit-ag.de> on 2019/05/08 19:18:49 UTC
JMS: fanout exchange and temporary queues
Hallo,
I hope this is the right place to ask about qpid jms.
I use qpid jms client 0.41.0 with qpidd broker 1.38.
I'm creating created a fanout exchange (qpid-config add exchange fan ABC)
and subscribe to it from java client using Topic and a MessageConsumer.
On server side a queue is created for each client with name like
"ID:84f6157f-8da4-42b4-a62a-dcc789f05806:1_qpid-jms:receiver:ID:71243772-61c8-4efc-9e85-eaca07de97e2:1:1:1:ABC"
which is not temporary (no autDel flag set).
If client crashes this queue remains on server side and is still filled
with messages.
How can we make the queue on server side temporary and deleted as soon as
client terminates?
Here's the code I use to read data from fanout:
String url = "amqp://10.194.4.10:5672";
String topicName = "FAN_BAEDS";
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
properties.setProperty("connectionfactory.myFactoryLookup", url);
properties.setProperty("topic.myTopicLookup", topicName);
// The configuration for the Qpid InitialContextFactory has been supplied in
// a jndi.properties file in the classpath, which results in it being picked
// up automatically by the InitialContext constructor.
Context context = new InitialContext(properties);
ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
Destination topic = (Destination)context.lookup("myTopicLookup");
Connection connection = factory.createConnection(System.getProperty("USER"), System.getProperty("PASSWORD"));
connection.setExceptionListener(new MyExceptionListener());
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(topic);
Thread.sleep(10000);
consumer.close();
session.close();
Best regards,
--
\ / | |
(OvO) | Mikhail Iwanow |
(^^^) | |
\^/ | E-mail: ivans@logit-ag.de |
^ ^ | |
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: JMS: fanout exchange and temporary queues
Posted by Gordon Sim <gs...@redhat.com>.
On 08/05/2019 9:28 pm, Gordon Sim wrote:
> On 08/05/2019 8:18 pm, Michael Ivanov wrote:
>> I hope this is the right place to ask about qpid jms.
>> I use qpid jms client 0.41.0 with qpidd broker 1.38.
>>
>> I'm creating created a fanout exchange (qpid-config add exchange fan ABC)
>> and subscribe to it from java client using Topic and a MessageConsumer.
>> On server side a queue is created for each client with name like
>> "ID:84f6157f-8da4-42b4-a62a-dcc789f05806:1_qpid-jms:receiver:ID:71243772-61c8-4efc-9e85-eaca07de97e2:1:1:1:ABC"
>>
>> which is not temporary (no autDel flag set).
>>
>> If client crashes this queue remains on server side and is still filled
>> with messages.
>>
>> How can we make the queue on server side temporary and deleted as soon as
>> client terminates?
>
> This is an issue with the broker. At present it is not setting the queue
> to be auto-delete if the sender settlement mode is unsettled. Given the
> source defines durable=NONE and expiryPolicy=LINK_DETACH that seems
> wrong as those values indicate that the receiver never expects to resume
> the subscription if disconnected. (I *think* the motivation was matching
> the behaviour of qpid::messaging and qpidd over amqp 0-10 when switching
> to 1.0 but it was a long time ago(!) so I can't be sure).
Fyi, I've pushed a fix for this (see
https://issues.apache.org/jira/browse/QPID-8310).
> However you can work around it by creating a 'topic' matching the
> exchange name with the appropriate policy set on it.
>
> E.g. qpid-config add topic ABC --argument exchange=ABC --argument
> qpid.lifetime-policy=delete-if-unused
>
> If the exchange is durable and you want the topic to be also, you can
> add --argument durable=true.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: JMS: fanout exchange and temporary queues
Posted by Joachim Weis <we...@logit-ag.de>.
Super, the work around is working.
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: JMS: fanout exchange and temporary queues
Posted by Gordon Sim <gs...@redhat.com>.
On 08/05/2019 8:18 pm, Michael Ivanov wrote:
> I hope this is the right place to ask about qpid jms.
> I use qpid jms client 0.41.0 with qpidd broker 1.38.
>
> I'm creating created a fanout exchange (qpid-config add exchange fan ABC)
> and subscribe to it from java client using Topic and a MessageConsumer.
> On server side a queue is created for each client with name like
> "ID:84f6157f-8da4-42b4-a62a-dcc789f05806:1_qpid-jms:receiver:ID:71243772-61c8-4efc-9e85-eaca07de97e2:1:1:1:ABC"
> which is not temporary (no autDel flag set).
>
> If client crashes this queue remains on server side and is still filled
> with messages.
>
> How can we make the queue on server side temporary and deleted as soon as
> client terminates?
This is an issue with the broker. At present it is not setting the queue
to be auto-delete if the sender settlement mode is unsettled. Given the
source defines durable=NONE and expiryPolicy=LINK_DETACH that seems
wrong as those values indicate that the receiver never expects to resume
the subscription if disconnected. (I *think* the motivation was matching
the behaviour of qpid::messaging and qpidd over amqp 0-10 when switching
to 1.0 but it was a long time ago(!) so I can't be sure).
However you can work around it by creating a 'topic' matching the
exchange name with the appropriate policy set on it.
E.g. qpid-config add topic ABC --argument exchange=ABC --argument
qpid.lifetime-policy=delete-if-unused
If the exchange is durable and you want the topic to be also, you can
add --argument durable=true.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org