As Kircheis answered in this question, you can set the message queue size when you add a message listener to your subscriber.
The rosjava Listener.java tutorial creates a listener like this:
Subscriber<std_msgs.String> subscriber = connectedNode.newSubscriber("chatter", std_msgs.String._TYPE);
subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
@Override
public void onNewMessage(std_msgs.String message) {
log.info("I heard: \"" + message.getData() + "\"");
}
});
When adding the message listener, you can specify a queue size:
int queueSize = 10;
subscriber.addMessageListener(new MessageListener<std_msgs.String>() {
@Override
public void onNewMessage(std_msgs.String message) {
log.info("I heard: \"" + message.getData() + "\"");
}
}, queueSize);
If you do not specify a queue size, the default size is 1.