Persistent blocking queue in Java?
TL; DR; I need to know if there is a lib with persistent blocking queues, which is a performance
I have a classic producer / consumer program They share a linkedblockingqueue to share data. I use the BlockingQueue #take method among consumers because I need them to always wait for new elements
The problem is that I have a lot of data. I can't lose them Even after consumers stop, producers can insist on generating some data I am considering implementing my BlockingQueue TA and using H2 to store / obtain some data after the threshold My main problem is that I need performance, and I need to use elements in the order they are created
Is there an implementation of persistent blocking queues that I can use for such things? If not, how can I achieve this goal?
Solution
I will use ActiveMQ lib and spring JMS, which is a usage example
Start broker
BrokerService broker = new BrokerService();
broker.addConnector("tcp://localhost:61616");
broker.start();
Read message
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
jmstemplate t = new jmstemplate(cf);
Message msg = t.receive();
send message
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
jmstemplate t = new jmstemplate(cf);
t.send("test",new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage("test");
}
});
