You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "code.junkie" <co...@gmail.com> on 2008/05/14 21:18:51 UTC

Newbie questions

Hi All,

I am planning to use ActiveMQ with a java project that I am working on. I am
planning to use a queue with persisted for reliable messaging ( guaranteed
messaging ). In that regard I have couple of questions for which I would
love to get some views on:

1) It is my understanding that I can either use ActiveMQ's APIs directly or
use via JMS ( using jndi). I am not sure what is the advantage of using the
JMS approach over using the activemq's apis directly?

2) I am planning to use batching for sending messages (persistent) to the
queue and was confused by reading
http://activemq.apache.org/how-do-i-enable-asynchronous-sending.html 
Should I still be using jms.useAsyncSend=true in case of batching ?

3) What is a good practice for consumer? Should I be reading the messages
from the queue within a transaction?  ( The reason being that I am using
Session.SESSION_TRANSACTED for the producer, so what should be the proper
way in consumer assuming producer and consumer processes at the same speed) 

Thanks in advance!
- Rakesh


3)   
-- 
View this message in context: http://www.nabble.com/Newbie-questions-tp17238878s2354p17238878.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Newbie questions

Posted by "code.junkie" <co...@gmail.com>.

rajdavies wrote:
> 
> Keeping to the JMS interface directly will give you more independence  
> - though things may be a little easier to get started if you use an  
> ActiveMQConnectionFactory directly.
> However,  instead of JNDI you could use Spring - see
> http://activemq.apache.org/spring-support.html
> 

I am not planning to use spring for my application. So I guess the better
option is to use the activemq APIs directly? Assuming I am always going to
use activemq, is there any other advantage of JMS in addition to providing
an activemq independent code for messaging?


rajdavies wrote:
> 
> Why not use transactions for the consumer ? - there maybe a marginal  
> improvement in performance - as it allows us to batch up the  
> acknowledgements back to the server.
> Note of caution though - ensure the transaction boundary is smaller  
> than the prefetch size - see
> http://activemq.apache.org/what-is-the-prefetch-limit-for.html
> it makes the broker have to work less!
> 
Got it. I see that the default prefetch limit for persistent queues is 1000.
So this would mean that I should not be processing more than 1000 messages
within a single transaction.

Thanks,
Rakesh

-- 
View this message in context: http://www.nabble.com/Newbie-questions-tp17238878s2354p17239387.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Newbie questions

Posted by j0llyr0g3r <ti...@wincor-nixdorf.com>.
Look in

$AMQ_HOME/example
-- 
View this message in context: http://www.nabble.com/Newbie-questions-tp17238878s2354p17252361.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Newbie questions

Posted by "code.junkie" <co...@gmail.com>.


rajdavies wrote:
> 
> Why not use transactions for the consumer ? - there maybe a marginal  
> improvement in performance - as it allows us to batch up the  
> acknowledgements back to the server.
> Note of caution though - ensure the transaction boundary is smaller  
> than the prefetch size - see
> http://activemq.apache.org/what-is-the-prefetch-limit-for.html
> it makes the broker have to work less!
> 

Also is there any sample code that I can refer for using transactions for
consumers?

Thanks,
Rakesh

-- 
View this message in context: http://www.nabble.com/Newbie-questions-tp17238878s2354p17239566.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Newbie questions

Posted by Rob Davies <ra...@gmail.com>.
On 14 May 2008, at 20:18, code.junkie wrote:

>
> Hi All,
>
> I am planning to use ActiveMQ with a java project that I am working  
> on. I am
> planning to use a queue with persisted for reliable messaging  
> ( guaranteed
> messaging ). In that regard I have couple of questions for which I  
> would
> love to get some views on:
>
Great! persistence is the default delivery mode for Queues - so no  
problems there.
> 1) It is my understanding that I can either use ActiveMQ's APIs  
> directly or
> use via JMS ( using jndi). I am not sure what is the advantage of  
> using the
> JMS approach over using the activemq's apis directly?
Keeping to the JMS interface directly will give you more independence  
- though things may be a little easier to get started if you use an  
ActiveMQConnectionFactory directly.
However,  instead of JNDI you could use Spring - see http://activemq.apache.org/spring-support.html
>
>
> 2) I am planning to use batching for sending messages (persistent)  
> to the
> queue and was confused by reading
> http://activemq.apache.org/how-do-i-enable-asynchronous-sending.html
> Should I still be using jms.useAsyncSend=true in case of batching ?
The easiest way to batch messages is to use a transaction - see http://activemq.apache.org/how-do-transactions-work.html 
  - that will send async anyway though the commit will be synchronous
>
>
> 3) What is a good practice for consumer? Should I be reading the  
> messages
> from the queue within a transaction?  ( The reason being that I am  
> using
> Session.SESSION_TRANSACTED for the producer, so what should be the  
> proper
> way in consumer assuming producer and consumer processes at the same  
> speed)
Why not use transactions for the consumer ? - there maybe a marginal  
improvement in performance - as it allows us to batch up the  
acknowledgements back to the server.
Note of caution though - ensure the transaction boundary is smaller  
than the prefetch size - see http://activemq.apache.org/what-is-the-prefetch-limit-for.html
it makes the broker have to work less!
>
>
> Thanks in advance!
> - Rakesh
>
>
> 3)
> -- 
> View this message in context: http://www.nabble.com/Newbie-questions-tp17238878s2354p17238878.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>





cheers,

Rob

http://open.iona.com/products/enterprise-activemq
http://rajdavies.blogspot.com/