activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From turkuaz07 <cvk...@gmail.com>
Subject activemq - delete consumed messages
Date Sun, 02 Mar 2014 20:50:09 GMT
I am using ActiveMQ in my app. My question is how to delete messages that ı
consumed successfully from kahadb. Because if it is not deleted, my db.data
file is growing up constantly.

I just wanna delete messages from db.data file after consumer got the
message, but how ?

Here is my consumer;

    ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:8182");
    Connection connection = connectionFactory.createConnection();
    connection.start();
    Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
    Destination destination = session.createQueue("TEST.FOO");
    MessageConsumer consumer = session.createConsumer(destination);

    MessageListener listner = new MessageListener() {
        int count = 0;

        public void onMessage(Message message) {
            if (message instanceof ObjectMessage) {
                ObjectMessage objectMessage = (ObjectMessage) message;
                ResponseDuration responseDuration = null;
                try {
                    responseDuration = (ResponseDuration)
objectMessage.getObject();
                    System.out.println("Received Time : " + new Date() +
"Received: " + responseDuration.toString());
                } catch (JMSException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                try {
                   
ResponseDurationOperations.insertResponseDurations(responseDuration);
                    count++;
                    System.out.println("Count = " + count);
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    };
    consumer.setMessageListener(listner);



--
View this message in context: http://activemq.2283324.n4.nabble.com/activemq-delete-consumed-messages-tp4678437.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message