当前位置:首页 » 编程语言 » webspherejava

webspherejava

发布时间: 2022-09-24 13:09:13

‘壹’ 如何在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中间件生成的javacore文件

在was启动前设置下面环境变量(可以加在启动脚本中)
export IBM_HEAPDUMP=true
export IBM_HEAP_DUMP=true
export IBM_HEAPDUMP_OUTOFMEMORY=true
export IBM_HEAPDUMPDIR=<directory path>
2.2please use set command to make sure you do not have DISABLE_JAVADUMP parameter
then start this cluster member.
用set命令检查参数设置,确保没有设置DISABLE_JAVADUMP,然后启动server
2.3when you find free memory < 50% when no heavy access, please run kill -3 <pid>
执行kill -3 <pid>命令可以生成javacore文件和heapmp文件(pid为was java进程的id号,可以用ps -ef|grep java 查到),可以多执行几次,按照下面操作进行
ps -ef > psef1.txt
ps aux > psaux1.txt
vmstat 5 10 > vmstat.txt
kill -3 <app server id>
wait for 2 mins
kill -3 <app server id>
wait for 2 mins
kill -3 <app server id>
netstat -an> netstat2.txt
ps -ef > psef2.txt
ps aux > psaux2.txt
将上面产生的 txt 文件和/usr/WebSphere/AppServer/javacore*文件和heapmp文件拷贝到本地,然后删除这些文件,因为这些文件会占用较大的文件系统空间。

‘叁’ websphere编译jsp生成的java类放在哪个目录

放在WebRoot\WEB-INF\classes\包名 文件夹下,建议楼主用那个MyEclipse写jsp,它会自己编译好了放在相应的文件夹下,不需要自己手动编译。 你那里再在classes下加个包名的文件夹,然后放进去吧

‘肆’ [Websphere]如何产生javacore文件和heapmp文件

在was启动前设置下面环境变量(可以加在启动脚本中) export IBM_HEAPDUMP=true export IBM_HEAP_DUMP=true export IBM_HEAPDUMP_OUTOFMEMORY=true export IBM_HEAPDUMPDIR=<directory path> 2.2please use set command to make sure you do not have DISABLE_JAVADUMP parameter then start this cluster member. 用set命令检查参数设置,确保没有设置DISABLE_JAVADUMP,然后启动server 2.3when you find free memory < 50% when no heavy access, please run kill -3 <pid> 执行kill -3 <pid>命令可以生成javacore文件和heapmp文件(pid为was java进程的id号,可以用ps -ef|grep java 查到),可以多执行几次,按照下面操作进行 ps -ef > psef1.txt ps aux > psaux1.txt vmstat 5 10 > vmstat.txt kill -3 <app server id> wait for 2 mins kill -3 <app server id> wait for 2 mins kill -3 <app server id> netstat -an> netstat2.txt ps -ef > psef2.txt ps aux > psaux2.txt 将上面产生的 txt 文件和/usr/WebSphere/AppServer/javacore*文件和heapmp文件拷贝到本地,然后删除这些文件,因为这些文件会占用较大的文件系统空间。

‘伍’ 在WebSphere中怎么在Java Library path中添加目录

当我们想为自己的应用程序添加库时,可以考虑从 WebSphere Admin Console 进行创建一个 Shared Library 并添加 jar 列表进去,以后在其它的 EAR (J2EE Application) 中选用这个 Shared Library (共享库)。

如果你的库是 JDBC 驱动程序,那可以在 JDBC Provider 中指定这些 jar 路径,不需要用 Shared Library 配置。

还有一种情况,如果你这些 jar 本身也是你们公司的产品并且是与当前正在部署的 ear 应用程序一起部署的,那么你可以用 WinRAR 这样的工具打开这个 ear 并把你的其它 jar 添加到这个 ear 文件中。然后重新部署这个 ear 文件,这个步骤要求你的 ejb-jar 中的 META-INF/MANIFEST.MF 中有 Class-Path 后面已经添加了这几个 jar 文件名字(短名,不需要目录前缀)。

‘陆’ 如何用java 监控websphere是否正常运行

告诉你一个简单的办法,你先看看你websphere的端口是多少,然后写几行代码,也去偿试监听这个端口,因为这个端口已经被占用了,会报异常,这时候说明websphere是正常的,只要你的这个小程序端口监听成功了,你就可以理解为websphere挂了

‘柒’ websphere打开java文件时候,中文乱码

原因是你的websphere默认打开的编码格式,和java文件的不一样
你配置一下websphere,改为utf-8,不行的话再改为其它的

热点内容
安卓系统的用户管理在哪里 发布:2024-05-04 23:12:27 浏览:429
我的世界服务器推荐电脑版免费 发布:2024-05-04 23:04:46 浏览:394
c程序如何编译 发布:2024-05-04 22:58:05 浏览:931
苹果手机怎么查看id密码 发布:2024-05-04 22:54:49 浏览:657
家有三相电如何配置音响设备 发布:2024-05-04 22:53:42 浏览:55
三星存储器已几乎满 发布:2024-05-04 22:47:38 浏览:736
mf90pos机密码是什么 发布:2024-05-04 22:24:04 浏览:750
编译预处理和函数区别 发布:2024-05-04 22:16:49 浏览:431
java复选框 发布:2024-05-04 22:13:24 浏览:529
安卓怎么玩页游 发布:2024-05-04 22:03:17 浏览:142