I want to send confirmation to Activemq when the value of x is 1 . If it is not 1 , I want to forward messages to Activemq . Then only Activemq again sends these messages to subscribers. For this, I wrote the following programs.
MessageConsumer.java:
public class Consumer extends HttpServlet { @Override protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { try { ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory("admin","admin","tcp://localhost:61617"); RedeliveryPolicy policy = new RedeliveryPolicy(); policy.setInitialRedeliveryDelay(1000L); policy.setMaximumRedeliveries(RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES); connectionFactory.setRedeliveryPolicy(policy); connectionFactory.setUseRetroactiveConsumer(true); Connection connection=connectionFactory.createConnection(); final Session session=connection.createSession(true, Session.AUTO_ACKNOWLEDGE); Topic queue=session.createTopic("MessageTesting"); javax.jms.MessageConsumer consumer=session.createConsumer(queue);
This is the right way to do this. Can you suggest me if there is an effective way.
Thanks.
source share