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

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

Introduction

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

Prototype

public int getMaxConcurrency() 

Source Link

Document

Return the maximum number of consumers/sessions to use.

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).
 *///from   www. ja v  a  2s  . 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()));
        }
    }
}