Durable topic error: Cannot get a client ID
kevin101 Nov 17, 2003 5:16 PMI want to write a MDB to handle Durable topic.
I get the following error, when I receiving message
Caused by: org.jboss.mq.SpyJMSException: Cannot get a client ID
at org.jboss.mq.Connection.askForAnID(Connection.java:542)
at org.jboss.mq.Connection.(Connection.java:167)
at org.jboss.mq.SpyConnection.(SpyConnection.java:47)
at org.jboss.mq.SpyXAConnection.(SpyXAConnection.java:37)
at org.jboss.mq.SpyXAConnectionFactory.createXATopicConnection(SpyXAConn
ectionFactory.java:144)
at org.jboss.jms.ConnectionFactoryHelper.createTopicConnection(Connectio
nFactoryHelper.java:141)
at org.jboss.ejb.plugins.jms.JMSContainerInvoker.init(JMSContainerInvoke
r.java:473)
at org.jboss.ejb.MessageDrivenContainer.init(MessageDrivenContainer.java
:164)
at org.jboss.ejb.Application.init(Application.java:204)
at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:373)
... 38 more
2003-11-17 17:29:12,122 INFO [JBossMain][AutoDeployer] - Started
Here are is my sample code:
package com.mdb;
public class MyMDB implements MessageDrivenBean, MessageListener
{
public void ejbCreate()
throws CreateException
{
System.out.println( "MyMDB.ejbCreate, MDB = " + hashCode() );
}
public void ejbRemove()
{
System.out.println( "MyMDB.ejbRemove, MDB = " + hashCode() );
}
final public void setMessageDrivenContext( MessageDrivenContext ctx )
{
this.ctx = ctx;
}
final protected MessageDrivenContext getMessageDrivenContext()
{
return ctx;
}
final protected Object getHome(final String name, final Class type)
throws NamingException
{
// first get the context
if( jndiContext == null ) jndiContext = new InitialContext();
// lookup the object
final Object home = jndiContext.lookup("java:comp/env/ejb/"+name);
// narrow the object
return PortableRemoteObject.narrow(home, type);
}
public void onMessage( final Message message )
{
System.out.println("Message arrived: " + message);
}
private MessageDrivenContext ctx = null;
private Context jndiContext = null;
}
// -- my ejb-jar.xml is as follows
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- the DTD -->
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<!-- description, et. al. -->
Durable MDB info
<display-name>Durable MDBs</display-name>
<!-- define all beans -->
<enterprise-beans>
<message-driven>
Durable MDB Listener
<display-name>DMDBListener</display-name>
<ejb-name>MyMDB</ejb-name>
<ejb-class>com.mdb.MyMDB</ejb-class>
<message-selector></message-selector>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>MyMDB</ejb-name>
<method-name>*</method-name>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
// -- my jboss.xml is as follows
<?xml version="1.0"?>
<!-- no DTD -->
<!-- ejb's -->
<enterprise-beans>
<message-driven>
<ejb-name>MyMDB</ejb-name>
<destination-jndi-name>topic/durTopic</destination-jndi-name>
<mdb-user>john</mdb-user>
<mdb-passwd>needle</mdb-passwd>
<mdb-subscriber-id>DurableMyId</mdb-subscriber-id>
</message-driven>
</enterprise-beans>
//--- my jboss.jcml is as follows. ( only jms topic info is listed here )
// -- my jbossmq-state.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE StateManager>
<!-- ===================================================================== -->
<!-- -->
<!-- JBossMQ StateManager Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- $Id: jbossmq-state.xml,v 1.1 2002/10/16 10:05:36 kramerg Exp $ -->
guest
guest
john
needle
DurableMyId
DurableMyId
durTopic
I guess there is someplace where I need to set clientId or Subscription-id. where should that be done ?
Any help in this regard is appreciated. Thank you