You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by leonardinius <le...@gmail.com> on 2007/01/22 09:51:32 UTC

Sending messages to topic with no consumers at all( with message TTL set on)

Hi and sorry for my poor English skills,
I have reached some problem.  I have to post some message to some
topic(dynamically created by request), which do not have any subscribers at
all. I MUST HAVE to support message TTL (time to live) feature, among other
I MUST HAVE to support another facility: at any time any could subscribe to
this topic and SHOULD receive all the messages sent. 

-I-]

If only one or more subscribers could be (already KNOWN), I could create
durable subscriptions for them, then close them, then (on reqyuaet) open and
consume, then unsubscribe. The problem is: 
a) I don't know subscribers and their count
b) All the subscribers( even subscribed to this topic after it creation
time, but before TTL ends up) SHOULD receive this message. 

-II-]

I am thinking about <retroactive> feature usage, but as far I understand, it
stores ALL the messages for the topic, so any DURABLE subscription to this
topic would get ALL the messages, not just the messages sent to topic after
the subscription made + those with TTL.

Thanks a lot for any comments and recomendations!
-- 
View this message in context: http://www.nabble.com/Sending-messages-to-topic-with-no-consumers-at-all%28-with-message-TTL-set-on%29-tf3052461.html#a8485399
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Sending messages to topic with no consumers at all( with message TTL set on)

Posted by James Strachan <ja...@gmail.com>.
>From an ActiveMQConnection or ActiveMQConnectionFactory set the policy
via this method

http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQConnection.html#setRedeliveryPolicy(org.apache.activemq.RedeliveryPolicy)

On 1/23/07, leonardinius <le...@gmail.com> wrote:
>
> how to progmatically set recovery policy, if i am using ConnectionFactory
>
> Hashtable props = new Hashtable();
>
> props.put(Context.INITIAL_CONTEXT_FACTORY,
> conf.getProperty("jms.connection.factory",
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory"));
> props.put(Context.PROVIDER_URL, conf.getProperty("jms.provider.url",
> "vm:(broker:(vm://localhost)?persistent=false&useJmx=false)?marshal=false"));
>
> javax.naming.Context ctx =  null;
> try{
>   ctx = new InitialContext(props);
> } catch(NamingException e) {
> ...
> }
>
> // Create a ConnectionFactory
> connectionFactory = (ActiveMQConnectionFactory)
> ctx.lookup("ConnectionFactory");
> connectionFactory.setClientID("xxxxxxxxx");
> connection = connectionFactory.createConnection();
> defaultSession = connection.createSession(true, Session.SESSION_TRANSACTED);
>
>
> James.Strachan wrote:
> >
> > ...
> > I'd recommend using <retroactive> and just implementing your own strategy
> > http://incubator.apache.org/activemq/retroactive-consumer.html
> > http://incubator.apache.org/activemq/subscription-recovery-policy.html
> >
> > and implement your own subscription recovery policy...
> > http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/broker/region/policy/SubscriptionRecoveryPolicy.html
> >
> > or you could go with the idea of using a single persistent
> > subscription using a wildcard. e.g. to FOO.> then all your generated
> > topics begin with FOO..> such as FOO.A or FOO.A.B.C.WHATNOT
> >
> > The only thing is I don't think we've yet implemented retroactive for
> > durable subscriptions - so the first idea is probably the easiest
> > (unless you wanna patch the code to support retroactive on persistent
> > topics).
> > ...
> >
>
> --
> View this message in context: http://www.nabble.com/Sending-messages-to-topic-with-no-consumers-at-all%28-with-message-TTL-set-on%29-tf3052461.html#a8517872
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Sending messages to topic with no consumers at all( with message TTL set on)

Posted by leonardinius <le...@gmail.com>.
how to progmatically set recovery policy, if i am using ConnectionFactory 

Hashtable props = new Hashtable();

props.put(Context.INITIAL_CONTEXT_FACTORY,
conf.getProperty("jms.connection.factory",
"org.apache.activemq.jndi.ActiveMQInitialContextFactory"));
props.put(Context.PROVIDER_URL, conf.getProperty("jms.provider.url",
"vm:(broker:(vm://localhost)?persistent=false&useJmx=false)?marshal=false")); 

javax.naming.Context ctx =  null;
try{
  ctx = new InitialContext(props);
} catch(NamingException e) {
...
}
			
// Create a ConnectionFactory
connectionFactory = (ActiveMQConnectionFactory)
ctx.lookup("ConnectionFactory");
connectionFactory.setClientID("xxxxxxxxx");
connection = connectionFactory.createConnection();
defaultSession = connection.createSession(true, Session.SESSION_TRANSACTED);


James.Strachan wrote:
> 
> ...
> I'd recommend using <retroactive> and just implementing your own strategy
> http://incubator.apache.org/activemq/retroactive-consumer.html
> http://incubator.apache.org/activemq/subscription-recovery-policy.html
> 
> and implement your own subscription recovery policy...
> http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/broker/region/policy/SubscriptionRecoveryPolicy.html
> 
> or you could go with the idea of using a single persistent
> subscription using a wildcard. e.g. to FOO.> then all your generated
> topics begin with FOO..> such as FOO.A or FOO.A.B.C.WHATNOT
> 
> The only thing is I don't think we've yet implemented retroactive for
> durable subscriptions - so the first idea is probably the easiest
> (unless you wanna patch the code to support retroactive on persistent
> topics).
> ...
> 

-- 
View this message in context: http://www.nabble.com/Sending-messages-to-topic-with-no-consumers-at-all%28-with-message-TTL-set-on%29-tf3052461.html#a8517872
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Sending messages to topic with no consumers at all( with message TTL set on)

Posted by James Strachan <ja...@gmail.com>.
On 1/22/07, leonardinius <le...@gmail.com> wrote:
>
> Hi and sorry for my poor English skills,
> I have reached some problem.  I have to post some message to some
> topic(dynamically created by request), which do not have any subscribers at
> all. I MUST HAVE to support message TTL (time to live) feature, among other
> I MUST HAVE to support another facility: at any time any could subscribe to
> this topic and SHOULD receive all the messages sent.
>
> -I-]
>
> If only one or more subscribers could be (already KNOWN), I could create
> durable subscriptions for them, then close them, then (on reqyuaet) open and
> consume, then unsubscribe. The problem is:
> a) I don't know subscribers and their count
> b) All the subscribers( even subscribed to this topic after it creation
> time, but before TTL ends up) SHOULD receive this message.
>
> -II-]
>
> I am thinking about <retroactive> feature usage, but as far I understand, it
> stores ALL the messages for the topic, so any DURABLE subscription to this
> topic would get ALL the messages, not just the messages sent to topic after
> the subscription made + those with TTL.
>
> Thanks a lot for any comments and recomendations!

I'd recommend using <retroactive> and just implementing your own strategy
http://incubator.apache.org/activemq/retroactive-consumer.html
http://incubator.apache.org/activemq/subscription-recovery-policy.html

and implement your own subscription recovery policy...
http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/broker/region/policy/SubscriptionRecoveryPolicy.html

or you could go with the idea of using a single persistent
subscription using a wildcard. e.g. to FOO.> then all your generated
topics begin with FOO..> such as FOO.A or FOO.A.B.C.WHATNOT

The only thing is I don't think we've yet implemented retroactive for
durable subscriptions - so the first idea is probably the easiest
(unless you wanna patch the code to support retroactive on persistent
topics).

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Sending messages to topic with no consumers at all( with message TTL set on)

Posted by leonardinius <le...@gmail.com>.
Please, give me some directions to look for. Any comments and recomendations
are pleased ,) 

-- 
View this message in context: http://www.nabble.com/Sending-messages-to-topic-with-no-consumers-at-all%28-with-message-TTL-set-on%29-tf3052461.html#a8485978
Sent from the ActiveMQ - User mailing list archive at Nabble.com.