简体   繁体   中英

Error is occurred while pushing the Message in IBM MQ Lite

I am using IBM MQ Light.

I am trying to push a message in IBM MQ Lite through java program, My Connection is well and good. When i run the program and check the Localhost it shows me that client is connected but after 3-4 seconds it is disconnected and Exception is thrown at console.

Following is my error log:

Problem with subscribe request: amqp:unauthorized-access: AMQXR0042E: A subscribe request was not authorized for channel PlainText received from 127.0.0.1. AMQXR0004E: MQSeries verb=SPISubscribe(String) returned cc=2(int) MQCC_FAILED rc=2035(int) MQRC_NOT_AUTHORIZED

A 2035 error code means you are not authorized. You may need to get more info to determine why your client is failing. You could use the MQS_REPORT_NOAUTH or MQSAUTHERRORS setting to get more info about the authority failure and what access is failing.

I have a sample code by which you can push the message in IBM MQ Lite

package com.Queue;
import com.ibm.mqlight.api.ClientOptions;

import com.ibm.mqlight.api.Delivery;
import com.ibm.mqlight.api.DestinationAdapter;
import com.ibm.mqlight.api.NonBlockingClient;
import com.ibm.mqlight.api.NonBlockingClientAdapter;
import com.ibm.mqlight.api.StringDelivery;


public class SendReceive2 
{
    public static void main(String[] cmdline) 
    {
        ClientOptions clientOpts = ClientOptions.builder().setCredentials("ad", "jms123").build();



        NonBlockingClient.create("amqp://localhost", clientOpts, new NonBlockingClientAdapter<Void>()
        {

            public void onStarted(NonBlockingClient client, Void context) 
            {
                client.subscribe("JmsQueue",  new DestinationAdapter<Void>() 
                {
                    public void onMessage(NonBlockingClient client, Void context, Delivery delivery) 
                    {
                        if (delivery.getType() == Delivery.Type.STRING)
                            System.out.println(((StringDelivery)delivery).getData());
                    }
                }, null, null);
            }
        }, null);





        NonBlockingClient.create("amqp://localhost", clientOpts, new NonBlockingClientAdapter<Void>()
        {
            public void onStarted(NonBlockingClient client, Void context) 
            {
                client.send("JmsQueue", "Jms Queue is Formed!", null);
            }

        }, null);






    }//main


}//class

Try it , It works in my case

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM