Example usage for org.springframework.jms.listener.endpoint JmsActivationSpecConfig getPrefetchSize

List of usage examples for org.springframework.jms.listener.endpoint JmsActivationSpecConfig getPrefetchSize

Introduction

In this page you can find the example usage for org.springframework.jms.listener.endpoint JmsActivationSpecConfig getPrefetchSize.

Prototype

public int getPrefetchSize() 

Source Link

Document

Return the maximum number of messages to load into a session.

Usage

From source file:org.springframework.jms.listener.endpoint.DefaultJmsActivationSpecFactory.java

/**
 * This implementation supports Spring's extended "maxConcurrency"
 * and "prefetchSize" settings through detecting corresponding
 * ActivationSpec properties: "maxSessions"/"maxNumberOfWorks" and
 * "maxMessagesPerSessions"/"maxMessages", respectively
 * (following ActiveMQ's and JORAM's naming conventions).
 *//* w ww .  ja v a 2 s  .  c o  m*/
@Override
protected void populateActivationSpecProperties(BeanWrapper bw, JmsActivationSpecConfig config) {
    super.populateActivationSpecProperties(bw, config);
    if (config.getMaxConcurrency() > 0) {
        if (bw.isWritableProperty("maxSessions")) {
            // ActiveMQ
            bw.setPropertyValue("maxSessions", Integer.toString(config.getMaxConcurrency()));
        } else if (bw.isWritableProperty("maxNumberOfWorks")) {
            // JORAM
            bw.setPropertyValue("maxNumberOfWorks", Integer.toString(config.getMaxConcurrency()));
        } else if (bw.isWritableProperty("maxConcurrency")) {
            // WebSphere
            bw.setPropertyValue("maxConcurrency", Integer.toString(config.getMaxConcurrency()));
        }
    }
    if (config.getPrefetchSize() > 0) {
        if (bw.isWritableProperty("maxMessagesPerSessions")) {
            // ActiveMQ
            bw.setPropertyValue("maxMessagesPerSessions", Integer.toString(config.getPrefetchSize()));
        } else if (bw.isWritableProperty("maxMessages")) {
            // JORAM
            bw.setPropertyValue("maxMessages", Integer.toString(config.getPrefetchSize()));
        } else if (bw.isWritableProperty("maxBatchSize")) {
            // WebSphere
            bw.setPropertyValue("maxBatchSize", Integer.toString(config.getPrefetchSize()));
        }
    }
}