hi all,
I want to use INDIVIDUAL_ACKNOWLEDGE like this:
I have one session and a receiver thread. this thread receive messages
to ten worker thread.
each worker thread acknowledge it's message
receiver thread:
while(true){
Message msg=receiver.receive();
put msg to a ConcurrentLinkedList;
}
Worker thread:
while(true){
Message msg=getMessgeFromLinkedList();
process msg;
msg.acknowledge();
}
is it thread safe?
I have debugged into ActiveMQMessageConsumer.acknowledge in 5.9.0
void acknowledge(MessageDispatch md, byte ackType) throws JMSException {
MessageAck ack = new MessageAck(md, ackType, 1);
session.sendAck(ack);
synchronized(deliveredMessages){
deliveredMessages.remove(md);
}
}
1. it seems remove message from deliveredMessages is synchronized
2. session.sendAck(ack);
sendAck(ack,false);
asyncSendPacket(ack);
connection.asyncSendPacket(command);
connection is thread safe, so message.acknowledge is thread-safe?