You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by HellKnight <he...@foxmail.com> on 2013/10/11 04:51:17 UTC

Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

I am using virtual topics but I've encountered a problem and I could not come
up with a perfect solution , so I decide to post it and I believe you guys
could help me .

My use case is something like this :
   a producer is monitoring a database.Once the database is updated, the
producer will send a message to anyone who is concerned about data updating
in that database, which means every message could be sent to one or more
consumers.However, don't assume that different messages will be sent to same
consumer groups.
    I am using virtual topics ,so the producer just sends message to a topic
called "VirtualTopic.AlertTopic". And as I have mentioned , there are
multiple users in my system just like ActiveMQ forum. Every user could run a
client program and login to the system , and the client program includes a
consumer to receive messages.  Messages sent to the virtual topic will be
dispatched to every queue, which means every message is actually sent to
every consumer, I have to use a message selector in the consumer side to
filter messages.
   I have created a queue named as "Consumer.UserID.VirtualTopic.AlertTopic"
for every system user. However, users will be add and removed dynamicly ,
and I should create a queue when adding a user and removing that queue when
removing the user from my system. If add a queue to ActiveMQ broker failed
due to exceptions, network failures etc.Then the user himself will find that
no message is received and he will just tell me ,so that is not a serious
problem.  
     However, if removing the user queue from activemq broker failed , there
will be some trouble. The user queue still exists, and since every message
sent to a virtual topic will be copied to every consumer queue , messages
will accumulating in the  queue that should be removed because the system
user who will consume that queue is removed from system managing database
and will never login again.  
     I've come up with two solutions:
1. Delete any user queue that has no active consumer for a long time , say ,
3 months. But this is imperfect, because it's possible that system user
would not login for months in our system , we consider that a normal
behaviour.

2. Purge a queue when it reach storage limits. This is good ,after all the
user won't like too many messages appear on his screen after a long offline
time.However, some users may hate this behaviour , they don't wonna miss any
notification messages

   I think there is an ideal way to deal with my problem. The message should
only be dispatched to the queues of its receivers, not all the queues. Is it
possible to do that?
 
    



--
View this message in context: http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Re:Re: Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

Posted by Christian Posta <ch...@gmail.com>.
because you didn't include them upfront... suonayi came up with valid
solution, but with missing details, it wasn't clear what your requirements
were.

back to the story...

why don't you just have a camel route that listens for a "delete user"
message and then uses JMX to remove the queue in question? your system
manager app can send the "delete user" message with the user to remove to
the queue the camel route is listening on.




On Thu, Oct 17, 2013 at 8:11 AM, HellKnight <he...@foxmail.com> wrote:

>    The login process is something like our forum , loginName and password
> is
> sent to some web service, the web service verify these data from what's
> stored in database of server side.If loginName and password is legal, the
> client program will receive an OK message and a consumer is created ,
> starting to receive ActiveMQ messages.
>    if user is offline, I want to keep messages for him as long as possible
> ,
> until the end of solar system will be the best, haha. Actually We don't
> want
> to tolerate any message loss.
>    If that user is deleted by some system manager , his queue will be
> deleted from broker.
>    Just out of curiosity, I think what I need should be some message
> routing
> mechanism inside broker when a message will be copied to multiple
> destinations , why you wanted me to offer these seemingly irrelavant info ?
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622p4672947.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Re:Re: Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

Posted by HellKnight <he...@foxmail.com>.
   The login process is something like our forum , loginName and password is
sent to some web service, the web service verify these data from what's
stored in database of server side.If loginName and password is legal, the
client program will receive an OK message and a consumer is created ,
starting to receive ActiveMQ messages.
   if user is offline, I want to keep messages for him as long as possible ,
until the end of solar system will be the best, haha. Actually We don't want
to tolerate any message loss.
   If that user is deleted by some system manager , his queue will be
deleted from broker.
   Just out of curiosity, I think what I need should be some message routing
mechanism inside broker when a message will be copied to multiple
destinations , why you wanted me to offer these seemingly irrelavant info ?




--
View this message in context: http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622p4672947.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Re:Re: Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

Posted by Christian Posta <ch...@gmail.com>.
Tell a little more about how users 'login', how long to keep the messages
if they log out, and what event causes a queue in the virtual topic to be
removed....


On Wed, Oct 16, 2013 at 10:35 PM, HellKnight <he...@foxmail.com> wrote:

> only online consumers could receive message if I use non-durable
> subscriptions. This couldn't meet my requirments.
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622p4672916.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Re:Re: Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

Posted by HellKnight <he...@foxmail.com>.
only online consumers could receive message if I use non-durable
subscriptions. This couldn't meet my requirments.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622p4672916.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re:Re: Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

Posted by SuoNayi <su...@163.com>.
Why not use nondurable subscription?
Seems it's a nondurable subscription usecase.




At 2013-10-16 20:59:03,"Matt Pavlovich" <ma...@gmail.com> wrote:
>A couple things to look into--
>
>1. Set a message expiration. You'll set this when producing the message. 
>2. gcInactiveDestinations  (this will garbage collect a destination if a consumer hasn't come around for X period of time)
>
>http://activemq.apache.org/delete-inactive-destinations.html
> 
>Hope this helps!
>
>On Oct 10, 2013, at 9:51 PM, HellKnight <he...@foxmail.com> wrote:
>
>> I am using virtual topics but I've encountered a problem and I could not come
>> up with a perfect solution , so I decide to post it and I believe you guys
>> could help me .
>> 
>> My use case is something like this :
>>   a producer is monitoring a database.Once the database is updated, the
>> producer will send a message to anyone who is concerned about data updating
>> in that database, which means every message could be sent to one or more
>> consumers.However, don't assume that different messages will be sent to same
>> consumer groups.
>>    I am using virtual topics ,so the producer just sends message to a topic
>> called "VirtualTopic.AlertTopic". And as I have mentioned , there are
>> multiple users in my system just like ActiveMQ forum. Every user could run a
>> client program and login to the system , and the client program includes a
>> consumer to receive messages.  Messages sent to the virtual topic will be
>> dispatched to every queue, which means every message is actually sent to
>> every consumer, I have to use a message selector in the consumer side to
>> filter messages.
>>   I have created a queue named as "Consumer.UserID.VirtualTopic.AlertTopic"
>> for every system user. However, users will be add and removed dynamicly ,
>> and I should create a queue when adding a user and removing that queue when
>> removing the user from my system. If add a queue to ActiveMQ broker failed
>> due to exceptions, network failures etc.Then the user himself will find that
>> no message is received and he will just tell me ,so that is not a serious
>> problem.  
>>     However, if removing the user queue from activemq broker failed , there
>> will be some trouble. The user queue still exists, and since every message
>> sent to a virtual topic will be copied to every consumer queue , messages
>> will accumulating in the  queue that should be removed because the system
>> user who will consume that queue is removed from system managing database
>> and will never login again.  
>>     I've come up with two solutions:
>> 1. Delete any user queue that has no active consumer for a long time , say ,
>> 3 months. But this is imperfect, because it's possible that system user
>> would not login for months in our system , we consider that a normal
>> behaviour.
>> 
>> 2. Purge a queue when it reach storage limits. This is good ,after all the
>> user won't like too many messages appear on his screen after a long offline
>> time.However, some users may hate this behaviour , they don't wonna miss any
>> notification messages
>> 
>>   I think there is an ideal way to deal with my problem. The message should
>> only be dispatched to the queues of its receivers, not all the queues. Is it
>> possible to do that?
>> 
>> 
>> 
>> 
>> 
>> --
>> View this message in context: http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Re: Is it possible to dispatch a message in the topic to only a certain queues while using virtual topic?

Posted by Matt Pavlovich <ma...@gmail.com>.
A couple things to look into--

1. Set a message expiration. You'll set this when producing the message. 
2. gcInactiveDestinations  (this will garbage collect a destination if a consumer hasn't come around for X period of time)

http://activemq.apache.org/delete-inactive-destinations.html
 
Hope this helps!

On Oct 10, 2013, at 9:51 PM, HellKnight <he...@foxmail.com> wrote:

> I am using virtual topics but I've encountered a problem and I could not come
> up with a perfect solution , so I decide to post it and I believe you guys
> could help me .
> 
> My use case is something like this :
>   a producer is monitoring a database.Once the database is updated, the
> producer will send a message to anyone who is concerned about data updating
> in that database, which means every message could be sent to one or more
> consumers.However, don't assume that different messages will be sent to same
> consumer groups.
>    I am using virtual topics ,so the producer just sends message to a topic
> called "VirtualTopic.AlertTopic". And as I have mentioned , there are
> multiple users in my system just like ActiveMQ forum. Every user could run a
> client program and login to the system , and the client program includes a
> consumer to receive messages.  Messages sent to the virtual topic will be
> dispatched to every queue, which means every message is actually sent to
> every consumer, I have to use a message selector in the consumer side to
> filter messages.
>   I have created a queue named as "Consumer.UserID.VirtualTopic.AlertTopic"
> for every system user. However, users will be add and removed dynamicly ,
> and I should create a queue when adding a user and removing that queue when
> removing the user from my system. If add a queue to ActiveMQ broker failed
> due to exceptions, network failures etc.Then the user himself will find that
> no message is received and he will just tell me ,so that is not a serious
> problem.  
>     However, if removing the user queue from activemq broker failed , there
> will be some trouble. The user queue still exists, and since every message
> sent to a virtual topic will be copied to every consumer queue , messages
> will accumulating in the  queue that should be removed because the system
> user who will consume that queue is removed from system managing database
> and will never login again.  
>     I've come up with two solutions:
> 1. Delete any user queue that has no active consumer for a long time , say ,
> 3 months. But this is imperfect, because it's possible that system user
> would not login for months in our system , we consider that a normal
> behaviour.
> 
> 2. Purge a queue when it reach storage limits. This is good ,after all the
> user won't like too many messages appear on his screen after a long offline
> time.However, some users may hate this behaviour , they don't wonna miss any
> notification messages
> 
>   I think there is an ideal way to deal with my problem. The message should
> only be dispatched to the queues of its receivers, not all the queues. Is it
> possible to do that?
> 
> 
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Is-it-possible-to-dispatch-a-message-in-the-topic-to-only-a-certain-queues-while-using-virtual-topic-tp4672622.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.