를 사용하여 MQ 서버의 큐 관리자에 연결할 수있다 -는 WebSphere MQ 오류가 발생했습니다 : 완성 코드 2 이유 코드 2058 . 나는 잘못된 큐 관리자 이름 때문에이 이유 코드를 알고 있습니다. 그러나 큐 관리자 이름은 정확합니다 ...가 어떻게 MQ 클라이언트</p> <p>오류가를 사용하여 MQ 서버에 메시지를 보내려고했다 MQ 클라이언트
WebSphere MQ 클라이언트를 설치 한 후 다음 명령을 실행했습니다. SET MQSERVER = QM_ORANGE/TCP/IPADDRESS (PORT NUMBER)
이 프로그램을 실행하십시오. public class MQSample {
// code identifier
static final String sccsid = "@(#) MQMBID sn=p750-002-131001_DE su=_FswqMCqGEeOZ3ui-rZDONA pn=MQJavaSamples/wmqjava/MQSample.java";
// define the name of the QueueManager
private static final String qManager = "QM_ORANGE";
// and define the name of the Queue
private static final String qName = "Q1";
/**
* Main entry point
*
* @param args - command line arguments (ignored)
*/
public static void main(String args[]) {
try {
// Create a connection to the QueueManager
System.out.println("Connecting to queue manager: " + qManager);
MQQueueManager qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open
//int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT;
int openOptions = MQConstants.MQOO_OUTPUT;
// int openOptions1 = MQConstants.MQOO_INPUT_AS_Q_DEF;
// Now specify the queue that we wish to open and the open options
System.out.println("Accessing queue: " + qName);
MQQueue queue = qMgr.accessQueue(qName, openOptions);
//MQQueue queue1 = qMgr.accessQueue(qName, openOptions1);
// Define a simple WebSphere MQ Message ...
MQMessage msg = new MQMessage();
// ... and write some text in UTF8 format
msg.writeUTF("Hello, World!");
// Specify the default put message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
// Put the message to the queue
System.out.println("Sending a message...");
queue.put(msg, pmo);
//
openOptions = MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING
+ MQC.MQOO_INPUT_SHARED;
queue = qMgr.accessQueue("QM_APPLE", openOptions,
null, // default q manager
null, // no dynamic q name
null); // no alternate user id
System.out.println("MQRead v1.0 connected.\n");
int depth = queue.getCurrentDepth();
System.out.println("Current depth: " + depth + "\n");
if (depth == 0) {
return;
}
MQGetMessageOptions getOptions = new MQGetMessageOptions();
getOptions.options = MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING
+ MQC.MQGMO_CONVERT;
while (true) {
MQMessage message = new MQMessage();
try {
queue.get(message, getOptions);
byte[] b = new byte[message.getMessageLength()];
message.readFully(b);
System.out.println(new String(b));
message.clearMessage();
} catch (IOException e) {
System.out.println("IOException during GET: " + e.getMessage());
break;
} catch (MQException e) {
if (e.completionCode == 2
&& e.reasonCode == MQException.MQRC_NO_MSG_AVAILABLE) {
if (depth > 0) {
System.out.println("All messages read.");
}
} else {
System.out.println("GET Exception: " + e);
}
break;
}
}
queue.close();
//_queueManager.disconnect();
// Disconnect from the QueueManager
System.out.println("Disconnecting from the Queue Manager");
qMgr.disconnect();
System.out.println("Done!");
}
catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode
+ " Reason Code " + ex.reasonCode);
ex.printStackTrace();
for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
System.out.println("... Caused by ");
t.printStackTrace();
}
}
catch (java.io.IOException ex) {
System.out.println("An IOException occured whilst writing to the message buffer: " + ex);
}
return;
}
}
예 sir ..이 동일한 기계에서 실행중인 큐 관리자 ...하지만 실제로 내 요구 사항은 코드를 IP 주소를 지정하지 않고 클라이언트 **를 통해 서버에서 실행중인 큐 관리자를 연결하는 것입니다 ** 어떤 명령을 사용하여 서버의 IP 주소를 설정할 수 있습니까 ?? –
아니요 환경 변수를 사용하지 않고 ... 내 프로그램에서 언급 한 것처럼 큐 관리자 이름 만 전달합니다 .... 나는 TCP를 포함하고 있습니다 : TCP : Library1 = DLLName1 KeepAlive = 예 ClntSndBuffSize = ClntRcvBuffSize 32768 = 32768 Connect_Timeout = 0 CHANNELS : DefRecon = YES ServerConnectionParms = QM_ORANGE.QM_APPLE1/TCP/192.168.1.5 (1414)' –
호스트 이름/IP 주소, 포트 및 채널이 없으면 응용 프로그램이 다른 시스템에서 실행중인 큐 관리자에 연결할 수 없습니다. – Shashi