中使用计划

农业机械2021年09月06日

java中使用websphere

webspheremq:用于传输信息具有跨平台的功能。

1安装webspheremq并启动

2webspheremq建立queueManager(如:MQSI_SAMPLE_QM)

3建立queue类型选择Local类型的(如lq)

3建立channels类型选择ServerConnection(如BridgeChannel)

java代码如下:

;

.*;

/*

*成功的访问mq的java类

*/

publicclassFirstMqTest{

//publicstaticvoidmain(String[]args[]){

//FirstMqTestfirst=newFirstMqTest();

//st();

//}

publicstaticvoidmain(Stringargs[]){

FirstMqTestfirst=newFirstMqTest();

st();

}

publicvoidtest(){

StringqManager=\"MQSI_SAMPLE_QM\";//QueueManagername

StringqName=\"lq\";//QueueName

try{

//configureconnectionparameters

stname=\"172.16.17.123\";//MQServernameorIP

//rt=1414;//listenrport

annel=\"BridgeChannel\";//Server-ConnectionChannel

SID=1381;

//CreateaconnectiontotheQueueManager

intln(\"Connectingtoqueuemanager:\"+qManager);

MueueManagerqMgr=newMueueManager(qManager);

//Setuptheoptionsonthequeuewewishtoopen

intopenOptions=OO_INPUT_AS_Q_DEF|OO_OUTPUT;

//Nowspecifythequeuethatwewishtoopenandtheopenoptions

intln(\"Accessingqueue:\"+qName);

Mueuequeue=cessQueue(qName,openOptions);

//DefineasimpleWebSphereMQMessage...

MQMessagemsg=newMQMessage();

//...andwritesometextinUTF8format

iteUTF(\"Hello,World!\");

//Specifythedefaultputmessageoptions

MQPutMessageOptionspmo=newMQPutMessageOptions();

//Putthemessagetothequeue

intln(\"Sendingamessage...\");

/*

*在此测试一下mq的传输次列

*

*/

for(intj=0;j5;j++){

Stringstr=\"test\";

str=str+j;

iteUTF(str);

t(msg,pmo);

}

t(msg,pmo);

//rstdefineaWebSphereMQmessage

//toreceivethedata

MQMessagercvMessage=newMQMessage();

//Specifydefaultgetmessageoptions

沥青混凝土的路面 MQGetMessageOptionsgmo=newMQGetMessageOptions();

//Getthemessageoffthequeue.

intln(\"...andgettingthemessagebackagain\");

t(rcvMessage,gmo);

//Anddisplaythemessagetext...

StringmsgText=adUTF();

intln(\"Themessageis:\"+msgText);

//Closethequeue

intln(\"Closingthequeue\");

ose();

//DisconnectfromtheQueueManager

intln(\"DisconnectingfromtheQueueManager\");

sconnect();

intln(\"Done!\");

}

catch(MQExceptionex){

intln(\"AWebSphereMQErroroccured:CompletionCode\"

+pletionCode+\"ReasonCode\"+asonCode);

}

catch(Exceptionex){

intln(\"AnIOExceptionoccuredwhilstwritingtothemessagebuffer:\"

+ex);

}

}

}

查看本文来源

钦州哪家医院治疗白癜风好
长春哪家治男科医院好
安顺白癜风医院哪家治疗好
相关阅读
千纸鹤有福了!易烊千玺加入两档五四晚会,他的优秀值得大家看见

五四青年人节已经来到,大家对于这天是又是期盼又是鄙视。期盼是因为当晚...

2024-11-18
恋就是让一个笨手笨脚的小女孩有人照顾 有人惦记 如果让她哭 你算什么男子汉 你算大笨蛋 艾特ta热门

恋人就是让一个笨手笨脚的莎拉有人照顾 有人惦记 如果让她不禁 你唯什么男...

2024-03-29
把女朋友当女儿养的男生也比较聪明 女孩子本来就是你越宠爱 她越可爱的 你给她足够的安全感和保护 她也

把女朋友当女儿饲的男生也非常聪明 女孩子本来就是你越好宠爱 她越好可爱...

2024-03-20
九分裤+乐福鞋,夏日这样穿,时髦又显高,很适合小个子

夏日傍晚,前往篇名,乐声徐徐下劝教蛙声一片。时节,冬天更为替,当夏日...

2024-03-05
直击调研 | 中材科技(002080.SZ):今年叶片出货量预计同比增加20% 十四五末期膜产能或达

7月5日,中会材科技应用领域(002080.SZ)在接受调研时表示,的公司是杂货店投...

2024-02-19
注意!这几种过道千万不要发朋友圈

录取结束,录取应考注意到了,这几种外面千万不能发博文!①录取准考证②...

2024-02-12
友情链接