payara / Payara

Payara Server is an open source middleware platform that supports reliable and secure deployments of Java EE (Jakarta EE) and MicroProfile applications in any environment: on premise, in the cloud or hybrid.
http://www.payara.fish
Other
886 stars 307 forks source link

JMS set client id in connection to use durable subscriber / FISH-789 #4603

Open r-alto opened 4 years ago

r-alto commented 4 years ago

Hallo,

I'm using "Payara Server 5.201 #badassfish (build 512)" from Docker.

I create: "JMS Ressource"->"Connection Factory"->"javax.jms.TopicConnectionFactory" as "jms/MyTopicConnectionFactory" with the parameter "clientID=4711".

If I try to create a DurableSubscriber I got an exception (javax.jms.JMSException: MQJMSRA_DC2001: Unsupported:setClientID():inACC=false:connectionId=2726772599957665024) if setting the client id of the connection (connection.setClientID("4711")).

This error occurs also if I don't set the parameter "clientID=4711" for the "Connection Factory".

If I don't set the client id the exception (com.sun.messaging.jms.IllegalStateException: createConsumer on JMSService:jmsdirect failed for connectionId:2726772600233384448 and sessionId:2726772600233924864 due to [B4135]: Cannot add durable consumer consumer. No ClientID was set on connection.) occurs it I do "session.createDurableSubscriber(topic, "consumer", "", false)".

What is wrong?

    Context context = null; 
    ConnectionFactory connectionFactory;
    Connection connection;
    Session  session;
    Topic topic;
    TopicSubscriber consumer;
    try {
        context = new InitialContext();
        connectionFactory = (TopicConnectionFactory) context.lookup("jms/MyTopicConnectionFactory");
        connection = connectionFactory.createConnection();
    connection.setClientID("4711");
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        topic = (Topic)context.lookup("jms/my/topic");
    consumer = session.createDurableSubscriber(topic, "consumer", "", false);
        consumer.setMessageListener( new MessageReceiveTwo() );
        connection.start();
    } catch (Exception e) {
        e.printStackTrace();
    }

Thanks Ralf

r-alto commented 4 years ago

It works if I create for every subscriber a connection factory with the paramter "clientID=xyz" and don't use the "setClientID" of the connection. But this solution is not verry useable, because i can't add subscribers dynamically.

OndroMih commented 4 years ago

Hi @r-alto , please, can you provide a simple to follow scenario how to reproduce this? A reproducer should ideally follow the SSCCE rules: http://www.sscce.org/. It will greatly help us to find the cause and fix it.

Please add the domain.xml file with all required configuration or a script with asadmin commands to set up the JMS resources. The Asadmin recorder might be helpful to generate the asadmin commands if you configure everything in Admin Console.

r-alto commented 4 years ago

Be sure the the "JMS Resoources -> Connection Factories" "jms/OrgaCardTopicConnectionFactory" and the "JMS Resoources -> JMS Destination Resources" "jms/orgacard/entity/topic" are defined.

Use project "jmslistenernative1" Open a remote debugging with the payara. Set a breakpoint at row "connection.setClientID("4712"); " and deploy the listener "jmslistenernative1". Step Over this instruction the exception is thrown. It doesn't matter what value you write into setClientID(), it only works if you set the parameter "clientID" in payaras "jms/OrgaCardTopicConnectionFactory". If you don't set the parameter "clientID" the durable subscriber doen't work.

r-alto commented 4 years ago

bug.zip The source code with a publisher and a listener.

AlanRoth commented 4 years ago

Hi @r-alto,

I have been able to reproduce the issue in 5.2020.6, I raised internal ticket FISH-789. We encourage you to submit a PR if you know the cause of the issue - since it may be a while before we get to fully investigate the cause of the error.

Thank you, Alan

r-alto commented 4 years ago

Sorry I don't know the cause of the issue.

ghost commented 3 years ago

I don't know if you solved, by the way I had the same issue. I was trying to deploy a project on a GlassFish server but already another project that used my jms/ConnectionFactory was deployed and I think the problem was that it couldn't find a free ConnectionFactory. By the way I undeployed the old project and I was able to deploy the new one. I hope that helps