JiveJdon Community Forums
在线386人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » J2EE/JavaEE/JEE/EJB/JSF等技术讨论
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 1 回复 / 1
 发表新帖子   回复该主题贴
easyinfonet

悄悄话
发表文章: 16
注册时间: 2003年07月22日 14:01
关于Jms 2003年10月09日 13:55 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
weblogic.jms.common.InvalidClientIDException: Client id, BibleJMSClient, is in use

BibleJMSClient 是我定义的client id

运行AsyncQueueReceiver 进行接受可以收到,队列中的消息


但是不关闭AsyncQueueReceiver 运行发送程序 BibleQueueSender 出现上面的错误








package bible.jms;

import javax.jms.*;
import javax.naming.*;
import java.util.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/


public class BibleQueueSender {
public BibleQueueSender() {
}

public static void main(String args[]) {
Context ctx= null;
Hashtable ht= new Hashtable();
QueueConnectionFactory qfactory=null;
QueueConnection qconn =null;
QueueSession qsession=null;
QueueSender qsender=null;
Queue q=null;
TextMessage textMsg=null;
String msg;
try {
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
ctx=new InitialContext(ht);
qfactory=(QueueConnectionFactory)ctx.lookup(
"BibleJMSFactory");
qconn =qfactory.createQueueConnection();
qsession=qconn.createQueueSession(false,javax.jms.QueueSession.AUTO_ACKNOWLEDGE);
q=(Queue) ctx.lookup(
"BibleJMSQueue");

qsender=qsession.createSender(q);
System.out.println(
"dddddddd...");
textMsg=qsession.createTextMessage();

for (int i=0;i<100;i++) {
msg=
"Message # " + i;
textMsg.clearBody();
textMsg.setIntProperty(
"serverity",i);
textMsg.setText(msg);
//System.out.println("Sending Message: "+ msg);
qsender.send(textMsg);
}

//textMsg.setText("stop");
//qsender.send(textMsg);
System.out.println(
"finished...");

}catch (Exception e){
e.printStackTrace();
}
finally {
try {
qsender.close();
qsession.close();
qconn.close();
}catch (Exception e){
e.printStackTrace();
}
}
}

}






package bible.jms;

import javax.jms.*;
import javax.naming.*;
import java.util.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/


public class AsyncQueueReceiver implements MessageListener {

private boolean finished =false;
private Context ctx= null;
private Hashtable ht= new Hashtable();
private QueueConnectionFactory qfactory=null;
private QueueConnection qconn =null;
private QueueSession qsession=null;
private QueueReceiver qreceiver=null;
private Queue q=null;


public void init() {
try {
ht= new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
ctx=new InitialContext(ht);
qfactory=(QueueConnectionFactory)ctx.lookup(
"BibleJMSFactory");
qconn =qfactory.createQueueConnection();
qsession=qconn.createQueueSession(false,javax.jms.QueueSession.AUTO_ACKNOWLEDGE);
q=(Queue) ctx.lookup(
"BibleJMSQueue");

qreceiver= qsession.createReceiver(q);
qreceiver.setMessageListener(this);
qconn.start();
} catch (Exception e){
e.printStackTrace();
}
}


public void close() throws JMSException
{
try {
qreceiver.close();
qsession.close();
qconn.close();
}catch (Exception e){
e.printStackTrace();
}

}


public AsyncQueueReceiver() {
}
public void onMessage(Message message) {
if (message instanceof TextMessage){
try {
TextMessage textMessage=(TextMessage)message;
String msg= textMessage.getText();
System.out.println(
"Received Message :"+ msg);


if (msg.equals(
"stop")) {
synchronized (this) {
finished=true;
this.notifyAll();
}
}
}catch (Exception e) {
e.printStackTrace();
}
}
}

public static void main(String args[]) {
try {
AsyncQueueReceiver qr= new AsyncQueueReceiver();
qr.init();
System.out.println(
"aaaaaaaaa...");

synchronized (qr) {
while(!qr.finished) {
try {
qr.wait();
}
catch (InterruptedException ie){}
}
qr.close();
}
}catch (Exception e){
e.printStackTrace();
}
}
}
weelee

悄悄话
发表文章: 1
注册时间: 2003年10月11日 03:34
Re: 关于Jms 2003年10月11日 03:37 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
clientid 只是针对订阅/发布方式的,在一般队列方式不可用.
在weblogic中将队列设置中的clientid 去掉即可.
这个主题有 1 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  每2分种自动备份发贴内容Ctrl-V粘贴取出,提问题前先查询标签列表

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com

anti spam