Question

I am using JMS with JBoss. But whenever i run the my consumer code i always get the below exception

[org.jboss.as.naming] (Remoting "sorabh216901" task-2) JBAS011806: Channel end notification received, closing channel Channel ID 091878ba (inbound) of Remoting connection 007ce8a6 to /192.168.2.47:53318

My Consumer class is as below:

public class TopicConsumer implements MessageListener{


    public static void main(String[] args) throws NamingException, JMSException {
        Context context = TopicConsumer.getInitialContext();
        try{
        System.out.println("Entering into the main method!!!");

        TopicConnectionFactory connectionFactory = (TopicConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
        Topic topic = (Topic) context.lookup("jms/topic/test");
        TopicConnection connection = connectionFactory.createTopicConnection("testuser", "testpassword");
        TopicSession session = connection.createTopicSession(true, TopicSession.AUTO_ACKNOWLEDGE);
        session.createSubscriber(topic).setMessageListener(new TopicConsumer());
        connection.start();
        System.out.println("Exiting from the main method!!!");
        }finally{
            //context.close();
        }

    }

    public void onMessage(Message arg0) {
        System.out.println("Incoming Message : " + arg0);
    }


    public static Context getInitialContext() throws NamingException{
        Properties props = new Properties();

        props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");
        props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
        props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
        props.put(Context.PROVIDER_URL,"remote://192.168.2.47:4447");


        props.put("jboss.naming.client.ejb.context", true);
        // username
        props.put(Context.SECURITY_PRINCIPAL, "testuser");
        // password
        props.put(Context.SECURITY_CREDENTIALS, "testpassword");

        return new InitialContext(props);

    }
}

When ever i ran the code i get the successful handshake in logs i.e.

    INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@cd0d2e, 
receiver=Remoting connection EJB receiver [connection=Remoting connection <1e03fce>,channel=jboss.ejb,nodename=sorabh216901]} on channel Channel ID 9823d1ac (outbound) of Remoting connection 004edf4a to /192.168.2.47:4447

But the program just closed and in server logs i get channel end notification.

Please suggest, what is wrong here.

Was it helpful?

Solution

Add the following line at the end of main method of TopConsumer class:

try {
            Thread.sleep(Integer.MAX_VALUE);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

This will not stop the JVM. And you won't get Channel End Notification exception

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top