2017-10-16 145 views
0

我使用IBM MQ 7.5版本(試用版)閱讀IBM MQ消息我不能用java

我創建了兩個隊列管理器(QM1和QM2)

下QM1:
端口:1421
隊列:Q1(本地隊列)
信道:CH1(接收機)

下QM2:
端口:1422
隊列:Q2(傳輸隊列),Q3(遠程隊列)
信道:CH1(發送者)

我可以通過QM2的隊列發送消息Q3QM1的隊列q1。我還可以通過q2接收和瀏覽消息。

但是,當我使用Java來讀取從Q1的消息我有一個錯誤

MQJE001: An MQException occurred: Completion Code 2, Reason 2009 
MQJE016: MQ queue manager closed channel immediately during connect  
Closure reason = 2009  
MQJE001: Completion Code 2, Reason 2009 

當我在IBM的網站,他們說,這可能會導致由於以下原因,檢查
http://www-01.ibm.com/support/docview.wss?uid=swg21226703

  1. 防火牆已終止連接。
  2. IOException導致套接字被關閉。
  3. 顯式操作導致套接字被一端關閉。
  4. 隊列管理器處於脫機狀態。
  5. 隊列管理器允許的最大通道數已打開。
  6. 隊列連接工廠(QCF)中的配置問題。

但是,以上所有都在我的系統中看起來不錯。我想念的是什麼,請讓我知道。

public static void main(String[] args) throws MQException { 

MQEnvironment.hostname="localhost"; 
MQEnvironment.channel="ch1"; 
MQEnvironment.port=1421; 
MQQueueManager qMgr= new MQQueueManager("QM1"); 
MQQueue outputQueue =qMgr.accessQueue("q1", MQC.MQOO_INQUIRE | MQC.MQOO_BROWSE | MQC.MQOO_INPUT_AS_Q_DEF); 


//Checking for messages in queue 
int i=outputQueue.getCurrentDepth(); 
System.out.println("Number of messages in queue: "+i); 


outputQueue.close(); 
qMgr.close(); 
qMgr.disconnect(); 
} 

添加:

版本的jar:

C:\ Program Files文件(x86)的\ IBM \ WebSphere MQ的\ java的\ LIB> java命令./com.ibm.mq .jar com.ibm.mq.MQJavaLevel
名稱:用於Java的WebSphere MQ類
版本:7.5.0。2
程度:p750-002-130627
生成類型:CH1(接收機)

MQEnvironment:生產

改變頻道已經收到的下面誤差

----- amqrmrsa.c : 898 -------------------------------------------------------- 
10/20/2017 02:17:37 - Process(16340.40) User(MUSR_MQADMIN) Program(amqrmppa.exe) 
        Host(user1) Installation(Installation1) 
        VRMF(7.5.0.2) QMgr(Receiver) 

AMQ9777: Channel was blocked 

EXPLANATION: 
The inbound channel 'SYSTEM.DEF.SVRCONN' was blocked from address '127.0.0.1' 
because the active values of the channel matched a record configured with 
USERSRC(NOACCESS). The active values of the channel were 'CLNTUSER(fresher)'. 
ACTION: 
Contact the systems administrator, who should examine the channel 
authentication records to ensure that the correct settings have been 
configured. The ALTER QMGR CHLAUTH switch is used to control whether channel 
authentication records are used. The command DISPLAY CHLAUTH can be used to 
query the channel authentication records. 
----- cmqxrmsa.c : 926 -------------------------------------------------------- 
10/20/2017 02:17:37 - Process(16340.40) User(MUSR_MQADMIN) Program(amqrmppa.exe) 
        Host(user1) Installation(Installation1) 
        VRMF(7.5.0.2) QMgr(Receiver) 

AMQ9999: Channel 'SYSTEM.DEF.SVRCONN' to host 'user1 (127.0.0.1)' ended 
abnormally. 

EXPLANATION: 
The channel program running under process ID 16340(5348) for channel 
'SYSTEM.DEF.SVRCONN' ended abnormally. The host name is 'user1 
(127.0.0.1)'; in some cases the host name cannot be determined and so is shown 
as '????'. 
ACTION: 
Look at previous error messages for the channel program in the error logs to 
determine the cause of the failure. Note that this message can be excluded 
completely or suppressed by tuning the "ExcludeMessage" or "SuppressMessage" 
attributes under the "QMErrorLog" stanza in qm.ini. Further information can be 
found in the System Administration Guide. 
----- amqrmrsa.c : 898 -------------------------------------------------------- 
+0

您應該查看QM1隊列管理器的AMQERR01.LOG,以查看客戶端獲得2009年時記錄的錯誤。請單擊編輯並使用這些詳細信息更新您的問題。另請提供您正在使用的MQ服務器的完整版本以及您的IBM MQ jar文件所來源的MQ的完整版本(如果它們不相同)。 – JoshMc

+0

你解決了你的問題嗎? – JoshMc

+0

還沒有,我嘗試按照@Roger的建議來使用svrconn頻道,但我無法做到。如果我在該類型中創建一個頻道,它不會啓動,所以我現在嘗試啓動channle的這種類型(svrconn)。 – Fresher

回答

1

信道之後.channel = 「CH1」;

MQ客戶端應用程序無法使用RECEIVER通道連接到隊列管理器。應用程序需要連接到SVRCONN通道。其次,爲MQ對象使用小寫名稱是一個不好的主意。 MQ將自動使用不包含引號的大寫名稱。所以,爲了避免問題,請使用大寫名稱。

+0

Roger,很好地捕捉了通道名稱,但是我發現即使在7.5版本嘗試將IBM MQ Classes for Java應用程序連接到RCVR通道時,Java應用程序收到的錯誤也是「 MQJE001:完成代碼爲'2',原因'2539'爲'MQRC_CHANNEL_CONFIG_ERROR',鏈接的異常報告'AMQ9547:遠程通道的類型不適合請求操作',在其記錄的隊列管理器上'AMQ9502:類型通道不適合請求的操作。' – JoshMc

+0

如果我使用MQ v6.0.2.7客戶機jar,那麼我能夠獲得MQ Classes for Java來產生'2009'錯誤,因此它可能是一個非常老的客戶機jar文件。如果頻道是錯誤的類型,不存在或被頻道授權規則阻止,那麼該版本會產生一個「2009」。 – JoshMc

0

最後我解決這個問題

  • 通過創建一個SVRCONN通道,而不是使用默認的SYSTEM.DEF.SVRCONN(我用TEST.SVRCONN
  • 而走到:頻道 - >頻道驗證記錄 - >刪除阻止用戶列表

按照上面的方法我可以解決這個問題。現在我可以閱讀來自Java應用程序的消息。