1. Queue
2. Remote Queue
3. Clustered Queue
4.Queue Manager Alias
-Remote Queue without Queue Name
5.Transmission Queue
-Local Queue with usage = XMITQ
6.Replay-to-Queue Alias
- Remote Queue without defining transmit Queue?
2011年11月30日 星期三
2011年11月29日 星期二
Websphere: sending message
1.Java Code for sending message through JMS :
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.QueueReceiver;
import javax.jms.Session;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueReceiver;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;
public class z_JMS_Test {
/**
* Main method
*
* @param args
*/
public static void main(String[] args) {
try {
for(int i=0; i<10;i++){
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// config connection
cf.setHostName("HOSTNAME");//host name
cf.setPort(20001);//QM port
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setChannel("SYSTEM.ADMIN.SVRCONN"); //channel for connection
cf.setQueueManager("MQ.T.GW1");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
//create session
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
//create sender & receiver queue
MQQueue sendqueue = (MQQueue) session.createQueue("queue:///Q.TEST.IN");
MQQueueSender sender = (MQQueueSender) session.createSender(sendqueue);
MQQueue receivequeue=(MQQueue) session.createQueue("queue:///Q.TEST.OUT");
QueueReceiver queueReceiver = session.createReceiver(receivequeue);
//create message
JMSTextMessage message = (JMSTextMessage) session.createTextMessage("test");
// message.setJMSCorrelationID("id1234567");
// message.setJMSDeliveryMode()
//setJMSReplyTo(reply);
connection.start();
sender.send(message);
System.out.println("\n Send SUCCESS\n");
Message inMessage = queueReceiver.receive(1000);
System.out.println(inMessage);
sender.close();
session.close();
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("\nFAILURE\n");
}
}
}
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.QueueReceiver;
import javax.jms.Session;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueReceiver;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;
public class z_JMS_Test {
/**
* Main method
*
* @param args
*/
public static void main(String[] args) {
try {
for(int i=0; i<10;i++){
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// config connection
cf.setHostName("HOSTNAME");//host name
cf.setPort(20001);//QM port
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setChannel("SYSTEM.ADMIN.SVRCONN"); //channel for connection
cf.setQueueManager("MQ.T.GW1");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
//create session
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
//create sender & receiver queue
MQQueue sendqueue = (MQQueue) session.createQueue("queue:///Q.TEST.IN");
MQQueueSender sender = (MQQueueSender) session.createSender(sendqueue);
MQQueue receivequeue=(MQQueue) session.createQueue("queue:///Q.TEST.OUT");
QueueReceiver queueReceiver = session.createReceiver(receivequeue);
//create message
JMSTextMessage message = (JMSTextMessage) session.createTextMessage("test");
// message.setJMSCorrelationID("id1234567");
// message.setJMSDeliveryMode()
//setJMSReplyTo(reply);
connection.start();
sender.send(message);
System.out.println("\n Send SUCCESS\n");
Message inMessage = queueReceiver.receive(1000);
System.out.println(inMessage);
sender.close();
session.close();
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("\nFAILURE\n");
}
}
}
標籤:
code,
JMS,
receive message,
sample,
send message,
Websphere
2011年11月8日 星期二
learning - linux command
-TYPE: find where the command from:
-ECHO: return the value of environment variable
-env: list all the environment variables
-set: list local environment variables
-export xxx: set xxx be the global environment variable
-read: read a line from conso
-alias lm "ls -ltr": let lm perform same operation as "ls -ltr"
-cmd ; cmd (不考慮指令相關性的連續指令下達)
-$? (指令回傳值) 與 && 或 ||
cmd1 && cmd2 ==> 1若 cmd1 執行完畢且正確執行($?=0),則開始執行 cmd2。
bash-4.1$ type ls
ls is hashed (/usr/bin/ls)
-ECHO: return the value of environment variable
bash-4.1$ echo $PATH
/opt/IBM/mqsi/6.1/jre15/ppc64/bin:/opt/IBM/mqsi/6.1/bin:/usr/bin
-env: list all the environment variables
-set: list local environment variables
-export xxx: set xxx be the global environment variable
-read: read a line from conso
-alias lm "ls -ltr": let lm perform same operation as "ls -ltr"
-cmd ; cmd (不考慮指令相關性的連續指令下達)
-$? (指令回傳值) 與 && 或 ||
cmd1 && cmd2 ==> 1若 cmd1 執行完畢且正確執行($?=0),則開始執行 cmd2。
- standard output 與 standard error output
簡單的說,標準輸出指的是『指令執行所回傳的正確的訊息』,而標準錯誤輸出可理解為『 指令執行失敗後,所回傳的錯誤訊息』。舉個簡單例子來說,我們的系統預設有 /etc/crontab 但卻無 /etc/vbirdsay, 此時若下達『 cat /etc/crontab /etc/vbirdsay 』這個指令時,cat 會進行:
- 標準輸出:讀取 /etc/crontab 後,將該檔案內容顯示到螢幕上;
- 標準錯誤輸出:因為無法找到 /etc/vbirdsay,因此在螢幕上顯示錯誤訊息
不管正確或錯誤的資料都是預設輸出到螢幕上,所以螢幕當然是亂亂的!那能不能透過某些機制將這兩股資料分開呢? 當然可以啊!那就是資料流重導向的功能啊!資料流重導向可以將 standard output (簡稱 stdout) 與 standard error output (簡稱 stderr) 分別傳送到其他的檔案或裝置去,而分別傳送所用的特殊字元則如下所示:
- 標準輸入 (stdin) :代碼為 0 ,使用 <(以file輸入) 或 << (以keyboard輸入,直到遇到"<
- 標準輸出 (stdout):代碼為 1 ,使用 > 或 >> ;
- 標準錯誤輸出(stderr):代碼為 2 ,使用 2> 或 2>> ;
2011年11月1日 星期二
Java Curl
Linux
1. install curl
yum install curl curl-devle
2. Download the source code and compile
http://curl.haxx.se/libcurl/java/
3.Compile the code:
gunzip curl-java-0.2.2.tar.gz
tar xvf curl-java-0.2.2.tar
cd curl-java-0.2.2
make
windows:
1. Download the source code and compile to dll
http://curl.haxx.se/libcurl/java/
compiled dll: http://www.gknw.de/mirror/curl/curl_java/
2.Copy to system32
3. or set the VM args in eclipse
ie Window->Preferences->Java->Installed JREs. Then choose your current JRE(JDK) and click Edit. Fill Default VM Arguments: -Djava.library.path=/usr/local/xuggler/lib.
ref: StackOverflow
Java Code
try {
// Loading up the shared JNI
System.loadLibrary("javacurl");
} catch (Exception e) {
e.printStackTrace();
}
test.java
// This test application accesses the Web site from Banco Santander, a Mexican bank, performs a login
// over SSL, receives a cookie and obtain the balance of a bank account, all using libcurl from Java
// import CurlGlue;
// import CurlWrite;
class test extends CurlIO {
public int handleString(byte s[])
{
/* output everything */
System.out.println("IIIIIIIIIII -------------- OOOOOOOOOOOOOOOOOOO");
try {
System.out.write(s);
}
catch (java.io.IOException moo) {
// nothing
}
return 0;
}
public static void main(String[] args)
{
// Bank account number and PIN - fake of course :)
String account = new String("1234567");
String pinCode = new String("1234");
CurlGlue cg;
try {
test cw = new test();
// Register callback write function
cg = new CurlGlue();
cg.setopt(CurlGlue.CURLOPT_WRITEFUNCTION, cw);
// Login to the bank's secure Web site, posting account number and PIN code
cg.setopt(CurlGlue.CURLOPT_URL, "https://www.santander.com.mx/SuperNetII/servlet/Login");
cg.setopt(CurlGlue.CURLOPT_SSLVERSION, 3);
cg.setopt(CurlGlue.CURLOPT_SSL_VERIFYPEER, 0); // attention! Insecure mode!!
cg.setopt(CurlGlue.CURLOPT_VERBOSE, 1);
cg.setopt(CurlGlue.CURLOPT_FOLLOWLOCATION, 1);
cg.setopt(CurlGlue.CURLOPT_POST, 1);
cg.setopt(CurlGlue.CURLOPT_COOKIEJAR, "cookie.txt");
cg.setopt(CurlGlue.CURLOPT_POSTFIELDS, "pag=login&pagErr=/index.html&usuario="+account+"&clave="+pinCode+"&irAmodulo=1");
cg.perform();
// Access the bank account balance re-using the session ID stored in memory inside a cookie
cg.setopt(CurlGlue.CURLOPT_URL, "https://www.santander.com.mx/SuperNetII/servlet/Cchequeras");
cg.setopt(CurlGlue.CURLOPT_SSLVERSION, 3);
cg.setopt(CurlGlue.CURLOPT_SSL_VERIFYPEER, 0); // attention! Insecure mode!!
cg.setopt(CurlGlue.CURLOPT_VERBOSE, 1);
cg.setopt(CurlGlue.CURLOPT_FOLLOWLOCATION, 1);
cg.setopt(CurlGlue.CURLOPT_COOKIEFILE, "cookie.txt");
cg.perform();
// The cookie.txt file is actually created now
cg.finalize();
} catch (Exception e) {
e.printStackTrace();
}
}
}
useful websit:http://chimpler.blogspot.com/2009/03/logging-to-ebay-with-java-curl.html
1. install curl
yum install curl curl-devle
2. Download the source code and compile
http://curl.haxx.se/libcurl/java/
3.Compile the code:
gunzip curl-java-0.2.2.tar.gz
tar xvf curl-java-0.2.2.tar
cd curl-java-0.2.2
make
windows:
1. Download the source code and compile to dll
http://curl.haxx.se/libcurl/java/
compiled dll: http://www.gknw.de/mirror/curl/curl_java/
2.Copy to system32
3. or set the VM args in eclipse
ie Window->Preferences->Java->Installed JREs. Then choose your current JRE(JDK) and click Edit. Fill Default VM Arguments: -Djava.library.path=/usr/local/xuggler/lib.
ref: StackOverflow
Java Code
try {
// Loading up the shared JNI
System.loadLibrary("javacurl");
} catch (Exception e) {
e.printStackTrace();
}
test.java
// This test application accesses the Web site from Banco Santander, a Mexican bank, performs a login
// over SSL, receives a cookie and obtain the balance of a bank account, all using libcurl from Java
// import CurlGlue;
// import CurlWrite;
class test extends CurlIO {
public int handleString(byte s[])
{
/* output everything */
System.out.println("IIIIIIIIIII -------------- OOOOOOOOOOOOOOOOOOO");
try {
System.out.write(s);
}
catch (java.io.IOException moo) {
// nothing
}
return 0;
}
public static void main(String[] args)
{
// Bank account number and PIN - fake of course :)
String account = new String("1234567");
String pinCode = new String("1234");
CurlGlue cg;
try {
test cw = new test();
// Register callback write function
cg = new CurlGlue();
cg.setopt(CurlGlue.CURLOPT_WRITEFUNCTION, cw);
// Login to the bank's secure Web site, posting account number and PIN code
cg.setopt(CurlGlue.CURLOPT_URL, "https://www.santander.com.mx/SuperNetII/servlet/Login");
cg.setopt(CurlGlue.CURLOPT_SSLVERSION, 3);
cg.setopt(CurlGlue.CURLOPT_SSL_VERIFYPEER, 0); // attention! Insecure mode!!
cg.setopt(CurlGlue.CURLOPT_VERBOSE, 1);
cg.setopt(CurlGlue.CURLOPT_FOLLOWLOCATION, 1);
cg.setopt(CurlGlue.CURLOPT_POST, 1);
cg.setopt(CurlGlue.CURLOPT_COOKIEJAR, "cookie.txt");
cg.setopt(CurlGlue.CURLOPT_POSTFIELDS, "pag=login&pagErr=/index.html&usuario="+account+"&clave="+pinCode+"&irAmodulo=1");
cg.perform();
// Access the bank account balance re-using the session ID stored in memory inside a cookie
cg.setopt(CurlGlue.CURLOPT_URL, "https://www.santander.com.mx/SuperNetII/servlet/Cchequeras");
cg.setopt(CurlGlue.CURLOPT_SSLVERSION, 3);
cg.setopt(CurlGlue.CURLOPT_SSL_VERIFYPEER, 0); // attention! Insecure mode!!
cg.setopt(CurlGlue.CURLOPT_VERBOSE, 1);
cg.setopt(CurlGlue.CURLOPT_FOLLOWLOCATION, 1);
cg.setopt(CurlGlue.CURLOPT_COOKIEFILE, "cookie.txt");
cg.perform();
// The cookie.txt file is actually created now
cg.finalize();
} catch (Exception e) {
e.printStackTrace();
}
}
}
useful websit:http://chimpler.blogspot.com/2009/03/logging-to-ebay-with-java-curl.html
訂閱:
文章 (Atom)