Ⅰ 有關websphere mq問題
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
myQMgr = new MQQueueManager ("QM1");
myQueue = myQMgr.accessQueue("TESTQ", openOptions);
MQMessage myMsg = new MQMessage ();
myMsg.messageFlags = MQC.MQMF_SEGMENTATION_ALLOWED;
MQPutMessageOptions pmo = new MQPutMessageOptions ();
String strMsg = "";
for (int i=0;i<=100;i++)
strMsg = strMsg + "Hello";
myMsg.write(strMsg.getBytes());
myQueue.put(myMsg,pmo);
System.out.println("Put message:\n" + strMsg);
myQueue.close();
myQMgr.disconnect();
QMgrSegReceiver.java:
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING;
myQMgr = new MQQueueManager ("QM1");
myQueue = myQMgr.accessQueue("TESTQ", openOptions);
MQMessage myMsg = new MQMessage ();
MQGetMessageOptions gmo = new MQGetMessageOptions ();
gmo.options = MQC.MQGMO_COMPLETE_MSG;
myQueue.get(myMsg, gmo);
byte[] b = new byte[myMsg.getMessageLength()];
myMsg.readFully(b);
String strMsg = new String(b);
System.out.println("Got message:\n" + strMsg);
myQueue.close();
myQMgr.disconnect();
Ⅱ websphere MQ JAVA 傳輸文件
QMgrSegSender.java:
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
myQMgr = new MQQueueManager ("QM1");
myQueue = myQMgr.accessQueue("TESTQ", openOptions);
MQMessage myMsg = new MQMessage ();
myMsg.messageFlags = MQC.MQMF_SEGMENTATION_ALLOWED;
MQPutMessageOptions pmo = new MQPutMessageOptions ();
String strMsg = "";
for (int i=0;i<=100;i++)
strMsg = strMsg + "Hello";
myMsg.write(strMsg.getBytes());
myQueue.put(myMsg,pmo);
System.out.println("Put message:\n" + strMsg);
myQueue.close();
myQMgr.disconnect();
QMgrSegReceiver.java:
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING;
myQMgr = new MQQueueManager ("QM1");
myQueue = myQMgr.accessQueue("TESTQ", openOptions);
MQMessage myMsg = new MQMessage ();
MQGetMessageOptions gmo = new MQGetMessageOptions ();
gmo.options = MQC.MQGMO_COMPLETE_MSG;
myQueue.get(myMsg, gmo);
byte[] b = new byte[myMsg.getMessageLength()];
myMsg.readFully(b);
String strMsg = new String(b);
System.out.println("Got message:\n" + strMsg);
myQueue.close();
myQMgr.disconnect();
Ⅲ 第三方中間件MQ、websphere、webSphere的作用和應用場景
MQ處理消息的,在分布環境下擴展進程間的通信,並支持多通訊協議、語言、應用程序、硬體和軟體平台。如果消息隊列較多可以用這個
WebLogic是用於開發、集成、部署和管理大型分布式Web應用、網路應用和資料庫應用的Java應用伺服器,基於J2EE,一般用在電子商務系統。
WebSphere 是一個模塊化的平台,可以在許多平台上運行,包括 Intel、Linux 和 z/OS。它可以創建高效的電子商務站點提高了網上交易的質量和數量。 把應用擴展到聯合的移動設備上使銷售人員可以為客戶提供更方便、更快捷的服務。 整合已有的應用並提供自動簡捷的業務流程。
Ⅳ WebSphere MQ中的隊列有幾種啊
可以簡單的把隊列看作一個容器,用來存放消息。隊列按其定義來分,可以分成本地隊列、遠程隊列、別名隊列和模型隊列。其中本地隊列是真正意義上的隊列實體,可以用來存放消息。而遠程隊列和別名隊列只是一種隊列的定義,指向另一個隊列實體。其中遠程隊列指向的是其他隊列管理器中的隊列,而別名隊列指向的是本地隊列管理器中的隊列。模型隊列有一點特殊,它雖然本身只是一個隊列的定義,描述了模型的屬性,但是當打開模型隊列的時候,隊列管理其就會以這個定義為模型,創建一個本地隊列,被成為動態隊列。
一個隊列管理器可以管轄多個隊列。但對於一個隊列只能隸屬於其中的一個隊列管理器。所以隊列在其所隸屬於的隊列管理器只能有唯一的名字,不能於同一個管理器中的其他的隊列重名。當消息添加到隊列中是,其預設被添加到最後。刪除消息時從頭開始。
(1)本地隊列:本地隊列按照功能又可以分為初始化隊列、傳輸隊列、目標隊列和死信隊列。其中初始化隊列用作消息觸發。傳輸隊列只是暫存待傳的消息,在條件許可的情況下,通過管道將消息傳送其他的隊列管理器。目標隊列是消息的目的地,可以長期存放信息。如果消息不能送達目標隊列,也不能路由出去,則被自動放入死信隊列。命令隊列指的是WebSphere MQ隊列管理器預定義的SYSTEM.ADMIN.COMMAND.QUEUE,任何的MQSC命令都可以發往改隊列,並被隊列管理器的命令伺服器(Command Server)接受處理。
MQXQH(傳輸信息頭,其中的RemoteQName和RemoteQMgrName兩個域指名了目標隊列和目標隊列管理器)
MQDLH(死信信息頭,其中DestQName和DestQMgrName兩個域指名了原消息的目標隊列和目標隊列管理器,Reason域指名了消息無法投遞的原因)。
MQMD(應答消息頭,其中ReplyToQ和ReplyToMgr分別表示應答隊列和應答隊列管理器)
(2)別名隊列:別名隊列的TARGQ屬性指名了其代表的目標隊列名稱,目標隊列通常是本地隊列。可以將別名隊列理解為指針。
(3) 遠程隊列:遠程隊列也是一個定義,使用了遠程隊列,你就可以不用知道目標隊列所在的隊列管理器了。
(4) 模型隊列:模型隊列定義了一套本地隊列的屬性集合。一旦打開模型隊列,隊列管理器就會按照這些屬性動態創建處一個本地隊列。模型隊列的DEFTYPE屬性可以取值為PERMDYN和TEMPDYN分別代表永久動態度列和臨時動態隊列。
Ⅳ websphere mq是什麼
IBM WebSphere MQ 是IBM公司提供的基於消息隊列的消息中間件。
國內相應的產品也有很多,如東方通科技的TONG-LinkQ等。
消息中間件服務於伺服器間的消息傳遞,並通過消息隊列機制保障其傳輸的穩定性。
Ⅵ java怎麼將mq接收的文件消息提取出來
WebSphere MQ 接收發送
添加mq jar
類介紹:
SendMSG:消息發送類。
Main():主方法。
SendMSG():消息發送方法。
方法描述:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package test;
public class SendMSG{
MQEnvironment.hostname = "192.168.10.201";
//通道類型為伺服器連接通道
MQEnvironment.channel = "tong";
MQEnvironment.CCSID = 1381;
//消息隊列埠號
MQEnvironment.port = 10618;
try{
//建立隊列管理器QM_SERVER為隊列管理器名稱
MQQueueManager qMgr = new MQQueueManager("test");
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF|MQC.MQOO_OUTPUTMQC.MQOO_INQUIRE;//建立隊列INITQ隊列名稱INITQ為本地隊列
MQQueue queue = qMgr.accessQueue("wanghui",openOptions,null,null,null);
System.out.println("成功建立通道");
MQMessage message = new MQMessage();
message.format = MQC.MQFMT_STRING;
message.characterSet = 1381;
message.writeString("王輝");
message.expiry = -1;//設置消息用不過期
queue.put(message);//將消息放入隊列
queue.close();//關閉隊列
qMgr.disconnect();//斷開連接
}catch(EOFExceptione){
e.printStackTrace();
}catch(MQExceptione){
e.printStackTrace();
}catch(Exceptione){
e.printStackTrace();
}
}
ReceiveMSG:消息接收類。
Main():主方法。
ReceiveMSG():消息接收方法。
public class ReceiveMSG {
MQEnvironment.hostname="192.168.10.201";//通道類型為伺服器連接通道
MQEnvironment.channel="tong";
MQEnvironment.CCSID=1381;
MQEnvironment.port=10618;
try{
//建立隊列管理器QM_SERVER為隊列管理器名稱
MQQueueManager qMgr = new MQQueueManager("test");
int openOptions=MQC.MQOO_INPUT_AS_Q_DEF|MQC.MQOO_OUTPUT|MQC.MQOO_INQUIRE;//建立隊列INITQ隊列名稱INITQ為本地隊列
MQQueue queue=qMgr.accessQueue("wanghui",openOptions,null,null,null);
System.out.println("成功建立通道");
MQMessage message= new MQMessage();
message.format=MQC.MQFMT_STRING;
message.characterSet=1381;
//從隊列中獲取消息
MQGetMessage Optionspmo=new MQGetMessageOptions();
queue.get(message,pmo);
Stringchars=message.readLine();
System.out.println(chars);
queue.close();//關閉隊列
qMgr.disconnect();//斷開連接
}catch(EOFExceptione){
e.printStackTrace();
}catch(MQExceptione){
e.printStackTrace();
}catch(Exceptione){
e.printStackTrace();
}
}
Ⅶ 如何在java中使用WebSphere MQ
websphere mq : 用於傳輸信息 具有跨平台的功能。
1 安裝websphere mq 並啟動
2 websphere mq 建立 queue Manager (如:MQSI_SAMPLE_QM)
3 建立queue 類型選擇 Local類型 的 (如lq )
3 建立channels 類型選擇Server Connection (如BridgeChannel)
java 代碼如下:
package test.mq;
import com.ibm.mq.*;
/*
* 成功的訪問mq 的java 類
*/
public class FirstMqTest {
// public static void main(String[] args[]){
// FirstMqTest first = new FirstMqTest();
// first.test();
// }
public static void main(String args[]){
FirstMqTest first = new FirstMqTest();
first.test();
}
public void test(){
String qManager = "MQSI_SAMPLE_QM"; //QueueManager name
String qName = "lq";//Queue Name
try {
//configure connection parameters
MQEnvironment.hostname="172.16.17.123";//MQ Server name or IP
//MQEnvironment.port=1414;//listenr port
MQEnvironment.channel="BridgeChannel";//Server-Connection Channel
MQEnvironment.CCSID =1381;
// 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 = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// 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);
// 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...");
/*
* 在此測試一下 mq 的傳輸次列
*
*/
for(int j=0;j< 5;j++){
String str ="test11111111111";
str = str+j;
msg.writeUTF(str);
queue.put(msg, pmo);
}
queue.put(msg, pmo);
// Now get the message back again. First define a WebSphere MQ message
// to receive the data
MQMessage rcvMessage = new MQMessage();
// Specify default get message options
MQGetMessageOptions gmo = new MQGetMessageOptions();
// Get the message off the queue.
System.out.println("...and getting the message back again");
queue.get(rcvMessage, gmo);
// And display the message text...
String msgText = rcvMessage.readUTF();
System.out.println("The message is: " + msgText);
// Close the queue
System.out.println("Closing the queue");
queue.close();
// 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);
}
catch (java.io.IOException ex) {
System.out.println("An IOException occured whilst writing to the message buffer: "
+ ex);
}
}
}
Ⅷ websphere和mq是啥關系
WebSphere 是 IBM 的軟體平台。WebSphere Application Server 是WebSphere 的核心基礎,在這個共同的基礎上產生了很多種產品。MQ中間件就是這些產品種的一種而已,所以通常稱WEBSHPERE MQ。
不知道這么說,你能理解不?