activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noel OConnor <noel.ocon...@gmail.com>
Subject Re: can I enable queue priority by plain java code
Date Tue, 04 Mar 2014 07:08:43 GMT
http://docs.oracle.com/javaee/5/api/javax/jms/MessageProducer.html#setPriority(int)


On Tue, Mar 4, 2014 at 11:57 AM, Li Li <fancyerii@gmail.com> wrote:

> I am using the following code snippet to send messages to a queue. How
> to make priority queue enabled?
> class Producer{
> private ActiveMQConnection conn;
> private QueueSender sender;
> private QueueSession session;
> public Producer() throws JMSException{
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory(
> "tcp://localhost:61616");
> conn = (ActiveMQConnection) connectionFactory.createConnection();
> conn.start();
>    session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
>
>     Queue queue = session.createQueue("TEST.QUEUE");
>
> sender = session.createSender(queue);
> sender.setDeliveryMode(DeliveryMode.PERSISTENT);
> }
> public void sendMsgs(int max) throws JMSException{
> //sender.setTimeToLive(10000);
> for(int i=0;i<max;i++){
> Message msg=session.createTextMessage("msg"+i);
> sender.send(msg);
> }
> }
> public void close(){
> if(this.session!=null){
> try {
> session.close();
> } catch (JMSException e) {
> e.printStackTrace();
> }
> }
> if(this.conn!=null){
> try {
> this.conn.close();
> } catch (JMSException e) {
> e.printStackTrace();
> }
> }
> }
> }
>
> On Mon, Mar 3, 2014 at 9:59 PM, Christian Posta
> <christian.posta@gmail.com> wrote:
> > If you build your broker using the java API you can do this by
> > creating the policy entry and using its setters directly.
> >
> > Is that what you're asking? Otherwise you set the priority on a
> > message by using the JMS APIs.
> >
> > On Mon, Mar 3, 2014 at 3:39 AM, Li Li <fancyerii@gmail.com> wrote:
> >> as in http://activemq.apache.org/how-can-i-support-priority-queues.html
> ,
> >> I should enable queue priority by xml configuration. is it possible to
> >> use java api to configure this?
> >
> >
> >
> > --
> > Christian Posta
> > http://www.christianposta.com/blog
> > twitter: @christianposta
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message