public class BatchReceiver extends Object implements Closeable
//send messages: async.sendTextMessage(QUEUE_NAME, jsonDocument); ... // repeat //receive messages: BatchReceiver br = async.getBatchReceiver(QUEUE_NAME, 100); List*** NEVER FORGET TO COMMIT AND CLOSE! ***messages = br.receiveTextMessages(500); //... process messages, commit to database br.commit(); // <<< -- deletes messages from queue br.close(); 
| Modifier | Constructor and Description | 
|---|---|
protected  | 
BatchReceiver(String queueName,
             long timeout,
             javax.jms.Connection connection)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()
Closes this resource (calling it is mandatory). 
 | 
void | 
commit()
Commits a current transaction. 
 | 
List<String> | 
receiveTextMessages(int maxSize)
Receives and returns  
size Strings from the queue. | 
void | 
rollback()
Rolls back current transaction. 
 | 
protected BatchReceiver(String queueName, long timeout, javax.jms.Connection connection) throws javax.jms.JMSException
javax.jms.JMSExceptionpublic List<String> receiveTextMessages(int maxSize)
size Strings from the queue.
 Presumes that messages in queue are TextMessage.maxSize - maximum number of messages to receivesize messages from the queue.public void commit()
public void rollback()
public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2020 JavaLite. All rights reserved.