저는 Java를 처음 사용하여 약간의 도움이 필요합니다. MQ 대기열에서 메시지를 읽은 다음 메시지를 txt 파일로 출력하고 마지막으로 대기열에서 원래 메시지를 삭제하려고합니다. 나는 다음을 생각해 냈지만 컴파일되지는 않는다. 도움이 될 것입니다. 감사합니다.Java를 사용하여 MQ에서 메시지를 읽는 방법
public class test
{
public static void main(String[] args);
{
MQQueueManager QMgr=new MQQueueManager(qManager);
int openOptions=MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_INPUT_SHARED | MQC.MQOO_BROWSE;
MQQueue queue=QMgr.accessQueue(queueName, openOptions);
MQMessage theMessage=new MQMessage();
MQGetMessageOptions gmo=new MQGetMessageOptions();
gmo.options=MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;
gmo.matchOptions=MQC.MQMO_NONE;
gmo.waitInterval=5000;
boolean thereAreMessages=true;
while(thereAreMessages){ **(Gives an "Illegal start of type" error)**
try{
queue.get(theMessage,gmo);
String msgText = theMessage.readString(theMessage.getMessageLength());
PrintStream out = new PrintStream(new FileOutputStream("C:\\Users\\js04279\\Desktop\\test.txt")):
System.setOut(out);
System.out.println("REMOVING.............................");
getMessageOptions.options =MQC.MQGMO_MSG_UNDER_CURSOR;
}
catch(MQException e){
if(e.reasonCode == e.MQRC_NO_MSG_AVAILABLE)
System.out.println("No more message available or retrieved");
thereAreMessages=false;
}
catch (IOException e){
System.out.println("ERROR: "+e.getMessage());
}
}
I got the following error messages:
"test.java:17: illegal start of type" - this was at the while statement
"test.java:35: <identifier> expected"
오류 메시지가 나타 납니까? – Robert
예 : "test.java:17 : 유형이 잘못되었습니다."라는 While 문과 "test.java:35 : expected"의 오류가 발생했습니다. –
smythie89
일부 구문 오류가 있습니다. 수동으로 자바 소스를 컴파일하고 컴파일러 오류를 해석하는 데 어려움을 겪지 않는 한,이 모든 작업을 수행하는 IDE를 사용하는 것이 좋습니다. [Eclipse는 대단히 인기 있고 확장 성이 높으며 무료입니다.] (https://www.eclipse.org/home/index.php) – mmcrae