2009-02-03 4 views
2

현재 WebSphere MQ를 사용하여 메인 프레임에서 데이터를 가져오고 때때로 MQ 측의 문제를 처리합니다.JMS를 사용하여 메인 프레임에 연결

MQ를 우회하여 JMS 대신 메인 프레임에서 데이터를 가져 오는 방법이 있는지 알고 싶습니다. 우리는 WebSphere Application Server 6.0.2를 사용합니다.

답변

3

미안하지만 JMS는 큐 관리자 구현이 아닌 드라이버 인터페이스 일뿐입니다.

JMS와 큐 관리자 사이에는 JDBC와 데이터베이스간에 동일한 차이점이 있습니다.

LLP, 안드레아

당신이 MQ에 대한 호출을 포장 종료됩니다 자바 측에서 JMS를 사용할 수 있습니다 물론
1

. 메시지 헤더에주의해야합니다. MQ를 다른 메시징 인프라로 교체하는 것은 메인 프레임이 대화 할 수있는 것에 달려 있습니다. MQ는 IBM 메인 프레임 시스템의 지원으로 인해 종종 선택됩니다.

그렉

0

논리를 찾아주세요,

  1. 우리는 ConnectionFactory에, 연결 및 세션 우리는 큐를 사용하여 큐 참조를 만들 필요가

  2. 을 사용하여 서버에 연결을 설정해야

  3. 우리가 작성한 메시지의 개체를 만들어야합니다. TextMessage를 사용하여 대기열로 보내려면

  4. 대기열과 상호 작용할 객체를 만들어야합니다. 여기, 메시지 생성자는 우리가 3 단계에서 생성 한 메시지를 보내는 데 사용하고 MessageConsumer는

구현을위한 아래의 코드를 찾아주세요 응답을 수신하는 데 사용

//Instantiate a Sun Java(tm) System Message Queue ConnectionFactory 
ConnectionFactory myConnFactory = new com.sun.messaging.ConnectionFactory(); 

String h = "HOSTNAME"; 
String p = "PORTNO"; 

// Set imqAddressList property 
((com.sun.messaging.ConnectionFactory)myConnFactory).setProperty(
com.sun.messaging.ConnectionConfiguration.imqAddressList, 
new StringBuffer().append("mq://").append(h).append(":").append(p).append("/jms").toString()); 

//Create a connection to the Sun Java(tm) System Message Queue Message Service. 
Connection myConn = myConnFactory.createConnection(); 

//Start the Connection created in step 3. 
myConn.start(); 

//Create a session within the connection. 
Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE); 

//Instantiate a Sun Java(tm) System Message Queue Destination administered object. 
Queue myQueue = new com.sun.messaging.Queue("<MODULENAME>"); 

//Create a message producer. 
MessageProducer myMsgProducer = mySess.createProducer(myQueue); 

//Create and send a message to the queue. 
TextMessage myTextMsg = mySess.createTextMessage(); 
myTextMsg.setText("<message>"); 

System.out.println("Sending Message: " + myTextMsg.getText()); 
myMsgProducer.send(myTextMsg); 

//Create a message consumer. 
MessageConsumer myMsgConsumer = mySess.createConsumer(myQueue); 

//Start the Connection created in step 3. 
myConn.start(); 

//Receive a message from the queue. 
Message msg = myMsgConsumer.receive(); 

//Retreive the contents of the message. 
if (msg instanceof TextMessage) { 
TextMessage txtMsg = (TextMessage) msg; 
System.out.println("Read Message: " + txtMsg.getText()); 
} 

//Close the session and connection resources. 
mySess.close(); 
myConn.close(); 
관련 문제