2 years ago

#35507

test-img

leandro.marques

My javax.jms.MessageListener stops receiving messages from IBM MQ Server

I am building a service that continuously consumes messages from a IBM MQ Queue. This service runs in a private cloud with 80 replicas (containers or PODs) listening to the queue. Observing the application logs, I can see about 20 PODs that are not consuming any messages, even though I can check the queue PUT metric counter which shows about 200 req/s (rush hour). Most of the messages stay in the queue for a while (20 seconds) and get expired.

During the non rush hour, the application receives about 40 req/s and can process all the messages without any being expired.

I wonder if there is a limit of active listeners that the IBM MQ Server support? If so, is there any way to increase this limit?

I create a JMSContext using this method:

public JMSContext buildContext() {
    if (this.context == null) {
        try {
            JmsConnectionFactory connection = JmsFactoryFactory.getInstance(JmsConstants.WMQ_PROVIDER).createConnectionFactory();
            String hostname = System.getenv("HOSTNAME");
            String appName = application.get();
            if (hostname != null && !hostname.trim().isEmpty()) {
                if (hostname.length() > 28) { // Tamanho máximo da propriedade WMQ_APPLICATIONNAME
                    appName = hostname.substring(hostname.length() - 28);
                } else {
                    appName = hostname;
                }
            }
            connection.setStringProperty(CommonConstants.WMQ_HOST_NAME, host.get());
            connection.setIntProperty(CommonConstants.WMQ_PORT, port.get());
            connection.setStringProperty(CommonConstants.WMQ_CHANNEL, channel.get());
            connection.setStringProperty(CommonConstants.WMQ_QUEUE_MANAGER, queueManager);
            connection.setStringProperty(JmsConstants.USERID, userid);
            connection.setStringProperty(JmsConstants.PASSWORD, password);
            connection.setBooleanProperty(JmsConstants.USER_AUTHENTICATION_MQCSP, isUserAuthenticationMqcsp);
            connection.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
            connection.setStringProperty(CommonConstants.WMQ_APPLICATIONNAME, appName);

            connection.setIntProperty(CommonConstants.WMQ_CLIENT_RECONNECT_OPTIONS, CommonConstants.WMQ_CLIENT_RECONNECT);

        LOGGER.info(String.format("buildContext - Parametros da fila a alta [%s],[%s],[%s],[%s],[%s]",
                host.get(), channel.get(), application.get(), queueManager, userid));

        this.context = connection.createContext();
        this.context.start();
        this.connectionFactory = connection;
    } catch (JMSException e) {
        LOGGER.error(String.format("buildContext - error - code: [%s], message: [%s].", e.getErrorCode(), e.getMessage()));
    }
}
return this.context;

}

I also configure my message listener using a separate thread as following:

    @Override
    public void run() {
        JMSContext context = factory.buildContext();

        this.creditoQueueConsumer = context.createConsumer(context.createQueue(Constantes.PREFIXO_QUEUE.concat(creditoQueue)));

        this.creditoQueueConsumer.setMessageListener(mqAltaPlataformaCreditoListener);
// mqAltaPlataformaCreditoListener is an implementation of MessageListener
        context.start();
}

The application seems to work fine, however there is a problem when some listeners suddenly stop receiving messages. I assume the MQ server works as a proxy and then distributes equally messages to all configured listeners, but for some reason, some of the listeners stop receiving messages. The MQ server team mentioned that some connection timeouts are occurring in the server side, as shown in the following picture.

enter image description here

Is there any configuration that can be done in the client to avoid those timeouts ou to avoid the service to stop receiving messages?

listener

ibm-mq

message-queue

consumer

0 Answers

Your Answer

Accepted video resources