ibm mq 教程_ibm mq_资讯导航:手机资讯_易配网(3)

电脑杂谈  发布时间:2019-04-30 07:10:27  来源:网络整理

MQGetMessageOptionsgmo=newMQGetMessageOptions();

gmo.options+=MQC.MQPMO_SYNCPOINT;

qQueue.get(retrievedMessage,gmo);

intlength=retrievedMessage.getDataLength();

byte[]msg=newbyte[length];

retrievedMessage.readFully(msg);

StringsMsg=newString(msg,"GBK");

System.out.println(sMsg);

}catch(RuntimeExceptione){

e.printStackTrace();

}catch(MQExceptione){

e.printStackTrace();

if(e.reasonCode!=2033)//没有消息

{

e.printStackTrace();

System.out

println("。33333".println("。/passwd".sendredirect(".getconnection(".println(".driver".sqlserver。

+e.completionCode

+"ReasonCodeis"

+e.reasonCode);

}

}catch(java.io.IOExceptione){

System.out

.println("Anerroroccurredwhilsttothemessagebuffer"

+e);

}

}

/**

*单元测试方法

*/

@Test

publicvoidtestMQ(){

MessageByMQmqst=newMessageByMQ();

mqst.init();

try{

getbytes('gbk'), 'utf-8')。} 由于这里将body中的字节读取出来编程了bodystr,注意上面红色部分那行代码,之前有问题时,没有添加charset.forname("utf-8"),那么由于在window上的默认编码为gbk,自然new bytearrayinputstream(bodystr.getbytes())中的byte编码为gbk,因此在调用filterchain.dofilter(servletrequest, response)时,到达controller的body编码就为gbk,从而导致无法以utf-8的编码解析json数据了,因此这里加上红色部分代码,顺利解决问题。string testword = new string("打印".getbytes("utf-8"), "gbk")。

mqst.GetMsg();

}catch(Exceptione){

e.printStackTrace();

}

}

/**

*释放资源

*/

@After

publicvoidrelease(){

try{

qQueue.close();

qMgr.disconnect();

}catch(MQExceptione){

System.out

.println("AWebSphereMQerroroccurred:Completioncode"

+e.completionCode+"ReasonCodeis"

ibm websphere mq jar_ibm websphere mq (1cpu)_ibm websphere mq搭建

+e.reasonCode);


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-95152-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...