Hey, what is THIS? Have you discussed this feature with anybody! You
certainly have not discussed it with me!
Why have you made those changes? Is it for your personal needs? Is it
because it is a generally good thing?
My first impression is that this is NOT a good thing. Why, when it looks
so tempting to be able to say to beginner: well just write a destination
name, if it don't exist it will be created for you.
But why it is also a BAD thing? Well, simply because you loose controll
over what is actually happening.
In client code: lookup("topic/MySpecialImportantTopic");
In MDB deployment descriptor: topic/MySpecialImpotantTopic
You see what will happen? Yes, the client will send its messages to one
topic (no automatic creation here), and the MDB will listen on ANOTHER
topic, namely a to the system unknown destination, since it was not
correctly spelled.
What do you other guys say on the list? Hiram?
//Peter
On 31 Maj, [EMAIL PROTECTED] wrote:
> User: thedug
> Date: 01/05/31 16:53:44
>
> Modified: src/main/org/jboss/ejb/plugins/jms JMSContainerInvoker.java
> Log:
> Add auto generation for topic/queue if topic/queue doesn't already exist.
> Uses the mbean server to create a new topic/queue..
>
> Revision Changes Path
> 1.11 +54 -7
>jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
>
> Index: JMSContainerInvoker.java
> ===================================================================
> RCS file:
>/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -u -r1.10 -r1.11
> --- JMSContainerInvoker.java 2001/05/07 19:19:57 1.10
> +++ JMSContainerInvoker.java 2001/05/31 23:53:44 1.11
> @@ -45,18 +45,24 @@
> import org.jboss.jms.jndi.JMSProviderAdapter;
> import org.jboss.jms.asf.ServerSessionPoolFactory;
>
> +import org.exolab.jms.client.JmsServerSessionPool;
> +
> import org.w3c.dom.Element;
>
> +import javax.management.MBeanServerFactory;
> +import javax.management.MBeanServer;
> +import javax.management.ObjectName;
> +
> /**
> * ContainerInvoker for JMS MessageDrivenBeans, based on JRMPContainerInvoker.
> * <description>
> - *
> + *
> * @see <related>
> * @author Peter Antman ([EMAIL PROTECTED])
> * @author Rickard Öberg ([EMAIL PROTECTED])
> * @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
> * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
> - * @version $Revision: 1.10 $
> + * @version $Revision: 1.11 $
> */
> public class JMSContainerInvoker implements
> ContainerInvoker, XmlLoadable
> @@ -205,7 +211,24 @@
>
> // Set up pool
> ServerSessionPoolFactory poolFactory =
>(ServerSessionPoolFactory)jbossContext.lookup(serverSessionPoolFactoryJNDI);
> -
> +
> + // jndiSuffix is merely the name that the user has given the MDB.
> + // since the jndi name contains the message type I have to split at the "/"
> + // if there is no slash then I use the entire jndi name.....
> + String jndiSuffix = "";
> + if(destinationJNDI != null){
> + int indexOfSlash = destinationJNDI.indexOf("/");
> + if(indexOfSlash != -1){
> + jndiSuffix = destinationJNDI.substring(indexOfSlash+1);
> + }else{
> + jndiSuffix = destinationJNDI;
> + }
> +
> + // if the jndi name from jboss.xml is null then lets use the ejbName
> + }else{
> + jndiSuffix = config.getEjbName();
> + }
> + MBeanServer server =
>(MBeanServer)MBeanServerFactory.findMBeanServer(null).iterator().next();
>
> if (destinationType.equals("javax.jms.Topic"))
> {
> @@ -230,7 +253,18 @@
> }
>
> // Lookup destination
> - Topic topic = (Topic)context.lookup(destinationJNDI);
> + // First Try a lookup.
> + // If that lookup fails then try to contact the MBeanServer and inoke
>a new...
> + // Then do lookup again..
> + String topicJndi = "topic/"+jndiSuffix;
> + Topic topic;
> + try{
> + topic = (Topic)context.lookup(topicJndi);
> + }catch(NamingException ne){
> + Logger.log("JndiName not found:"+topicJndi + "...attempting
>to recover");
> + server.invoke(new ObjectName("JMS","service","JMSServer"),
>"newTopic", new Object[]{jndiSuffix}, new String[] {"java.lang.String"});
> + topic = (Topic)context.lookup(topicJndi);
> + }
>
> pool = poolFactory.
> getServerSessionPool(
> @@ -293,10 +327,23 @@
> queueConnection = queueFactory.createQueueConnection();
> }
>
> - // Lookup destination
> - Queue queue = (Queue)context.lookup(destinationJNDI);
> + // Lookup destination
> + // First Try a lookup.
> + // If that lookup fails then try to contact the MBeanServer and inoke a
>new...
> + // Then do lookup again..
> + String queueJndi = "queue/"+jndiSuffix;
> + Queue queue;
> + try
> + {
> + queue = (Queue)context.lookup(queueJndi);
> + }
> + catch(NamingException ne){
> + Logger.log("JndiName not found:"+queueJndi + "...attempting to
>recover");
> + server.invoke(new ObjectName("JMS:service=JMSServer"), "newQueue",
>new Object[]{jndiSuffix}, new String[] {"java.lang.String"});
> + queue = (Queue)context.lookup(queueJndi);
> + }
>
> - pool = poolFactory.
> + pool = poolFactory.
> getServerSessionPool(
> queueConnection,
> maxPoolSize,
>
>
>
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-development
--
Jobba hos oss: http://www.tim.se/weblab
------------------------------------------------------------
Peter Antman Technology in Media, Box 34105 100 26 Stockholm
Systems Architect WWW: http://www.tim.se
Email: [EMAIL PROTECTED] WWW: http://www.backsource.org
Phone: +46-(0)8-506 381 11 Mobile: 070-675 3942
------------------------------------------------------------
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development