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.po...@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 <fancye...@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