Lookup of connections & queues

I'm new to JMS, and would appreciate it if someone could please clear up this confusion...
There appear to be 2 ways to access a Queue object:
Method 1:  Through a session, i.e:
QueueConnection con= factory.createQueueConnection();
QueueSession session = con.createQueueSession(...);
Queue q= session.createQueue("queue:///MYQ");
Method 2:  Lookup through InitialContext (provided by vendor):
Context ctx=new InitialContext(...)
Queue  q=(Queue) ctx.lookup(...)I've managed to get it working both ways.
And I realize method 2 has the advantage of configuring queues/managers through your container admin, rather than inside the code.
But apart from that, are there any other important differences ? would it affect my application design or performaces ?
In particular, suppose we put aside the initialization times ( assume "ctx.looup" or "session.createQueue" are called once on application startup). Will there be a difference in performance - will it take longer to send/receive JMS messages ?
Thanks very much !

Hi,
If you have a look at the JavaDoc for the QueueSession.createQueue() it states the following:
"This facility is provided for the rare cases where clients need to dynamically manipulate queue identity. It allows the creation of a queue identity with a provider-specific name. Clients that depend on this ability are not portable.
Note that this method is not for creating the physical queue. The physical creation of queues is an administrative task and is not to be initiated by the JMS API. The one exception is the creation of temporary queues, which is accomplished with the createTemporaryQueue method."
From this, it looks like they are suggesting Method 2 as the preferred approach. I would doubt that there is a performance hit by using Method 1.....but I don't have any concrete information to support that inference. I hope this helps?
Cheers,
J.

Similar Messages

  • Trouble performing a lookup for the queue on JBoss/axis

    Hi all,
    I am trying to develop a webservice which can write messages to a JMS queue and read from a JMS topic. JBoss is the application server, and i have installed tomcat axis 1.1 on the server for developing the webservice.
    I am having trouble accessing looking up the queue, to be clear this is the code im using,
    QueueConnectionFactory cf_callset;
    TopicConnectionFactory cf_resultset;
    try
         Hashtable props = new Hashtable();
         props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
         props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
         Context ctx = new InitialContext(props);
    cf_callset = (QueueConnectionFactory)ctx.lookup("XAConnectionFactory");
    cf_resultset = (TopicConnectionFactory) ctx.lookup("XAConnectionFactory");
    m_callSetQueue = (Queue)ctx.lookup("queue/CallSetQueue");
    m_resultSetTopic = (Topic)ctx.lookup("topic/ResultSetTopic");
    catch(NamingException ne)
         Logger log = new Logger();
         log.logError("221","Failed To Initialize JMS", ne.getStackTrace().toString());
    this code snippet throws a NamingException saying CallSetQueue not bound. but when i run this code snippet as a console application, it works just fine.
    i have also observed a strange thing.
    this class is in a different package, so i have copied this package files in to the /axis/web-inf/classes folder.
    I tried in a different way by, adding this code snippet to a method in the .jws file itself and it worked fine. im really confused as to why this is happening.
    Any help will be greatlly appreciated.
    Thanks

    Thank you for your response - I'm not sure I understand your question,  but hopefully this will help: I created a table, then dragged numeric fields into the cells from the object library. I clicked the numeric fields to name them Fed 1, Fed 2 etc.
    Does that help?

  • Iplanet 6.0  connection queue question

    ConnectionQueue:
    Current/Peak/Limit Queue Length 0/25/4096
    Total Connections Queued 933189
    Average Queueing Delay 0.66 milliseconds
    What is an acceptable average queueing delay? Not sure when I should really worry about it or what can be done (more acceptor threads?)

    How does one go about tuning the queing delay ? Ours seems pretty high by comparision. Maybe it has something to do with the high number of images in our document pages (over 100, thank the developers for that one) or our web application performance.
    webservd pid: 7069
    Sun ONE Web Server 6.1 B08/22/2003 12:37 (SunOS DOMESTIC)
    Server started Wed Jan 21 11:32:24 2004
    Process 7069 started Wed Jan 21 11:32:24 2004
    ConnectionQueue:
    Current/Peak/Limit Queue Length 0/30/4096
    Total Connections Queued 3498501
    Average Queueing Delay 196.97 milliseconds
    ListenSocket ls1:
    Address http://aaa.bbb.ccc.ddd:80
    Acceptor Threads 1
    Default Virtual Server https-ourcompany.com
    ListenSocket ls2:
    Address https://aaa.bbb.ccc.ddd:443
    Acceptor Threads 1
    Default Virtual Server https-ourcompany.com
    KeepAliveInfo:
    KeepAliveCount 5/256
    KeepAliveHits 2253199
    KeepAliveFlushes 0
    KeepAliveRefusals 0
    KeepAliveTimeouts 18852
    KeepAliveTimeout 60 seconds
    SessionCreationInfo:
    Active Sessions 1
    Total Sessions Created 128/256
    CacheInfo:
    enabled yes
    CacheEntries 1024/1024
    Hit Ratio 8881467/9097232 ( 97.63%)
    Maximum Age 300
    Native pools:
    NativePool:
    Idle/Peak/Limit 1/1/128
    Work Queue Length/Peak/Limit 0/0/0
    Server DNS cache disabled
    Async DNS disabled
    Performance Counters:
    Average Total Percent
    Total number of requests: 2988117
    Request processing time: 0.1857 554994.5000
    default-bucket (Default bucket)
    Number of Requests: 2988117 (100.00%)
    Number of Invocations: 46667042 (100.00%)
    Latency: 0.0002 685.7922 ( 0.12%)
    Function Processing Time: 0.1855 554308.6875 ( 99.88%)
    Total Response Time: 0.1857 554994.5000 (100.00%)
    Sessions:
    Process Status Function
    7069 response service-dump

  • Failure(1443): connection queue size is full, 6.1 SP2 restarts

    Hi All,
    I am getting the following issue with 6.1 SP2.
    In the error logs I get the following statement "failure 1443: connection queue size is full" with the ConnQueueSize as 256 in my magnus.conf file.
    Now there are cases that once the above errors comes for a long time the SP2 restarts by itself ie the request handler process id gets changed and comes up with a new process.The watch dog process remains same.
    Please let me know why does the SP2 restarts by itself once the above failure comes or I am doing something silly.
    Thanks in advance.
    Regards
    -A

    Server restarts automatically only if it crashes. Do you have any stack trace?
    Kindly consider upgrading to newer service pack (SP7). The issue might have been resolved in newer service packs.

  • JNDI lookup in connection pooling

    Hi
    I am trying to use connection pooling to establish adatabase connection. I am using Tomcat webserver. I have dbcp-coommon.*.jar and database connector jars in catalina lib. I have configured server.xml and web.xml as explained in the Tomcat sie. But I am not getting the initial lookup of (java:comp/env) I get the error as
    javax.naming.NameNotFoundException: Name java:comp is not bound in this Context.
    I have tried creating a seperate context in catalina\localhost. But still the error is same. Any idea... Reply please

    I still get the error as follows
    Name java:comp is not bound in this Context
    javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
         at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
         at org.apache.naming.NamingContext.lookup(NamingContext.java:151)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at com.troy.util.ConnectionPool.doGet(ConnectionPool.java:33)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:595)
    Any ideas reply...

  • Slow DNS Lookups after connecting via PPP VPN

    I have this very annoying problem and just can't seem to find a method to resolve it.
    When I connect to my work network via a PPP VPN connection, all internet connectivity thereafter takes forever to do a DNS lookup. So when I browse the internet it takes ages before the page is displayed back.
    If I also do a ping in finder for a random URL, www.google.com for example, it sits there for nearly a minute before I get a response. If I then immediately perform the ping again, I get a response straight away. So it seems once it's resolved the domain name, it gets stored in a cache somewhere. If I try another domain name, I get the same delay and then it eventually gets through.
    As soon as I close the VPN connection, service is resumed and DNS lookups work fast.
    I've also made sure I've unchecked the option to "Send all traffic over VPN connection".
    I've also set my 'Service Order' to have my wireless Airport connection in the No #1 position.
    The other thing I've tried is deleting the default route (via Terminal) and adding one manually that points to my wireless router, again without success.
    Does anyone have any other ideas I could try? I've also recently re-installed a fresh copy of Leopard in case something was stuffed up, but the problem is still there after installation.
    Hoping someone has an easy solution!
    Many thanks

    I seem to have found a work-around. There is probably a neater way of doing this but here goes.
    Here is my setup:
    Airport Wireless to my home router
    PPP VPN connection to my office windows network
    3G connection via mobile phone
    My aim was to be able to connect to my office network via wireless at home or via my cellular data connection, but continue to route all non-work traffic via the main connection (wireless/3G).
    The #1 problem I had once I connected to my office VPN on either wireless or 3G, was that DNS lookups to general internet sites took forever. So to get around this, I created TWO VPN connections to my office network in Network Preferences and in both connections I made sure the option to send all traffic over VPN was left UNCHECKED.
    The first connection I then designated for use when connecting wirelessly at home. Here I manually added the IP address of my home router as a DNS entry.
    The second connection I did the same by adding a new DNS entry, except here I used the DNS server of my cellular data connection, in this case T-Mobile UK.
    When connecting to my office network I just use either of the above connections depending on whether I am connecting wirelessly at home or via my mobile phone.
    It seems a bit long winded I grant you, but after literally months of trying to resolve this annoying problem, this appears to be the only fix that works.
    The downfall of this would be that DNS resolution to any servers on your office network might not work, but that isn't a problem for me since I manually add any servers I use at work to my local hosts file. This negates any need for DNS lookups and actually speeds up access to my work servers.
    In amongst this I did several reboots, so you give your machine a reboot once you've completed the above steps, just in case.
    The 3G connection won't work for you if your provider changes the DNS server every time you connect, but this is unlikely.
    If anyone's got any comments, I'd love to hear them.
    Cheers
    Phil

  • Why isn't there an iTunes Connection Queue?

    It's been about 2 hours for me trying to connect and reconnect to iTunes for the final step in my 2.0 update. I understand that there is a huge volume of people trying to do the same thing which is causing the server overload, but why isn't there a queue so that we can at least wait in line?
    **** Poor Planning = **** Poor Performance

    A line?! Instead of a 2 hour wait, you'd be looking at a 2 day wait if that was the case.

  • Ringback Tone not heard in Arc Connect queue

    Hi All,
    Got a strange problem thats been ongoing for a while now.
    Our customer has recently migrated to SIP and since this point I am having to force the external ringback tone using command disable-early media 180. In addition they have an Arc connect solution which now when transferring callers into the queues and then being passed to an agent, they do not hear ringback there is just silence. In queue messages and MOH is heard within the queue.
    I'm pretty sure this is a DTMF issue but I have tried everything to rectify this with no luck.
    We are unable to create a SIP trunk to the CUBE as CUCM 7.1.2 does not support this hence h323 gateway.
    The flow is as follows :-
    SIP > CUBE > h323 > CUCM > Arc
    CUCM Version :- 7.1.2
    Arc Version :- 5.1.0.403
    I've attached sanitised config.
    Any help would be much appreciated.
    Cheers

    You most likely right by saying this is DTMF related, I had a similar issue in the past, going H323<>SIP on a CUBE and played with the dtmf settings on the dial peers, and ended up with:
    dtmf-relay h245-alphanumeric rtp-nte 

  • NoClassDefFoundError while accessing JMS Queue from JDev 10.1.3.3

    Hi,
    I'm trying to get a handle of a JMS queue, which resides on Oracle App Server 10.1.3.4, from a Java Program which I'm trying to run from JDeveloper 10.1.3.3.
    I'm trying to make an RMI connection to the App server from JDeveloper by passing following information to the intialContext:
    env.put("java.naming.factory.initial",
    "oracle.j2ee.rmi.RMIInitialContextFactory");
    env.put(Context.PROVIDER_URL,
    "ormi://wafedabpelqa10.corp.weyer.pri:12402");
    env.put("java.naming.security.principal","oc4jadmin");
    env.put("java.naming.security.credentials","welcome1");
    Where the above information is related to our App Server.
    I'm successfully able to establish an RMI connection from JDev to Oracle App Server and can lookup datasources created on the App server using their
    JNDI names. However if I try to look up a JMS Queue from the App server using its JNDI name, I get an error as:
    java.lang.NoClassDefFoundError: oracle/tip/adapter/api/OracleConnectionFactory
    I have also tried to use the value "com.evermind.server.rmi.RMIInitialContextFactory" for "java.naming.factory.initial",
    however I still get the same error.

    Hi,
    this should work and you need to download the rmi library http://www.oracle.com/technology/software/products/ias/htdocs/utilsoft.html
    thanks
    # String queueName = "jms/MyJMSQueue";
    # String queueConnectionFactoryName = "jms/MyJMSQCF";
    # Context ctx;
    # try { 
    # Properties parm = new Properties();
    # parm.setProperty("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
    # parm.setProperty("java.naming.provider.url","ormi://localhost:23791/");
    # parm.setProperty("java.naming.security.principal","oc4jadmin");
    # parm.setProperty("java.naming.security.credentials","welcome");
    # ctx = new InitialContext(parm);
    # QueueConnectionFactory connectionFactory =
    # (QueueConnectionFactory)ctx.lookup(queueConnectionFactoryName);
    # connection = connectionFactory.createQueueConnection();
    # connection.start();
    # session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    # queue = (Queue)ctx.lookup(queueName);
    # sender = session.createSender(queue);
    # receiver = session.createReceiver(queue);
    # } catch (JMSException je) { 
    # throw new RuntimeException("Fout opgetreden bij het starten ",
    # je);
    # } catch (Throwable t) { 
    # throw new RuntimeException("Fout opgetreden bij het starten ",
    # t);
    # }

  • MessageDriven Bean problem.Working but the queues r not getting cleared

    I have written a simple message driven bean.It just sends a message to an another queue myadapterqueue
    on getting a message .
    It is working. But the problem is if I restart my application server then it again reads the messages which had been sent to it earlier.Also the queue size is
    not getting to 0 bytes after it has consumed messages.
    My application server is JBOSS2.4.3
    I think I have to specify some attributes in the
    descriptor files.But how??????????????
    Here is my code
    import java.util.*;
    import javax.ejb.*;
    import javax.jms.*;
    import javax.naming.*;
    public class MyMessageBean implements javax.ejb.MessageDrivenBean,javax.jms.MessageListener
         private QueueConnection connect=null;
         private QueueSession session=null;
         private QueueSender sender =null;
    private Queue sendQueue=null;
    private MessageDrivenContext ctx = null;
         public void setMessageDrivenContext(MessageDrivenContext mdc){
              System.out.println ("In setMessageDrivenContext--------------");
              this.ctx=mdc;
         public void ejbCreate(){
              try{
                   System.out.println ("Message bean Created--------------");
                   InitialContext jndi=new InitialContext();
                   QueueConnectionFactory queueFactory=(QueueConnectionFactory) jndi.lookup("ConnectionFactory");
                   connect=queueFactory.createQueueConnection();
                   session=connect.createQueueSession (true,Session.AUTO_ACKNOWLEDGE);
                   System.out.println ("After session creation--------------");
                   sendQueue=(Queue)jndi.lookup("queue/myadapterqueue");
                   System.out.println("************ queue/myadapterqueue");
              sender=session.createSender (sendQueue);
              System.out.println ("Before Connection start--------------");
              connect.start();
              }catch(javax.jms.JMSException jmse){
                   System.out.println ("In ejbcreate exception-------------------");
                   throw new javax.ejb.EJBException();
              }catch(javax.naming.NamingException jne){
                   System.out.println ("In ejbcreate exception-------------------");
                   throw new javax.ejb.EJBException();
         public void ejbRemove(){
              try{
              System.out.println("ejbRemove done");
              connect.close ();
                   this.ctx=null;
              }catch (javax.jms.JMSException jmse){
                   System.out.println ("In ejbremove exception-------------------");
                   System.out.println("ejbRemove excetion");
                   throw new javax.ejb.EJBException();
         public void onMessage(Message msg){
              try{
              this.sender.send (msg);
              this.session.commit();
              System.out.println(" Message");
         }catch(javax.jms.JMSException jmse ){
              jmse.printStackTrace();
    here are my descriptors
    ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar>
    <ejb-jar>
    <enterprise-beans>
    <message-driven>
    <ejb-name>MyMessageBean</ejb-name>
    <ejb-class>MyMessageBean</ejb-class>
    <transaction-type>Container</transaction-type>
    <message-driven-destination>
    <destination-type>javax.jms.Queue</destination-type>
    </message-driven-destination>
    </message-driven>
    </enterprise-beans>
    </ejb-jar>
    and the correspong xml file for the application server here is jboss.xml
    ?xml version="1.0" encoding="UTF-8"?>
    <jboss>
    <enterprise-beans>
         <message-driven>
              <ejb-name>MyMessageBean</ejb-name>
              <configuration-name>Standard Message Driven Bean</configuration-name>
              <destination-jndi-name>queue/MyMessageBeanQ</destination-jndi-name>
         </message-driven>
    </enterprise-beans>
    </jboss>

    it is unclear whether you are commiting on the first queue or second one.
    but it appears like you have created a transactional problem across the two queues. although you commit on the first queue, this commit is not extended to the second queue.
    things will be fine unless you get an exception of shutdown.
    if you shut your message provider down first then you cannot send the message to the second queue. (assuming that queue 2 is also on the same server)
    if you shut your MB app server down then you may be in the middle of accepting a onMessage callback from the first queue.
    do you have another MB that registers this one as a listener, or are you infact sending a message back onto the same queue...
    public void onMessage(Message msg){
    try{
         this.sender.send (msg);
         //your server may shutdown here and leave messages on the first queue. and send extra messages on the second.
            this.session.commit();
            System.out.println(" Message");
    } catch(javax.jms.JMSException jmse ){
            jmse.printStackTrace();
    }

  • JMS Message Queue - stuck in

    I am on SOA SUITE 11.1.17
    I have a jms queue set up and am able to successfully send messages to it using the SOA JMS Adapter.  I am able to succesfully listen to a queue using a JMS adapter in a different project.
    However, here when I try to "listen" to the queue using a java program, the message is "received" in my java program and processed as it should be.  The java program is running in a while loop, so it stays running.
    On the queue, when the java program reads it, the message is moved to the "Messages Pending" column.  When I kill the java program, the message is returned to the "Messages Current"
    Would anyone have any ideas about this?  We have an existing java based program isn't properly "closing" the message.
    I tried:
    1.  placing msg.acknowledge() in the code, since the documentation states that messages that are in "Messages Pending" have been read, but not acknowledged or committed -- but this does nothing.
    2.  Setting the expiration on the message to 1, but that is a hack.  I would rather fix the problem than use a hack.
    Anyone have any ideas what is wrong?
    Thank you,
    Stuart
    import java.io.IOException;
    import java.io.InputStreamReader;
    import javax.jms.Connection;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageListener;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    public class JMSListenAndRespond extends JMSQueueHandler implements MessageListener {
      private Session jmsSession = null;
      private MessageConsumer jmsMessageConsumer = null;
      private Connection jmsConnection = null;
      int counter = 1 ;
      public static void main(String[] args) throws Exception {
        InputStreamReader commandBuffer = null;
        char command = '\0';
          // first listen for any messages
          JmsDataObject q = new JmsDataObject();
          q.setJmsCF("jms/TestConnectionFactory");
          q.setJmsQueue("jms/TestJMSQueue");
          q.setServerPwd("welcome1");
          q.setServerLogin("weblogic");
          q.setUrl("t3://localhost:7101");
          q.setJmsMsg("na -- we are listinging...");
        JMSListenAndRespond lis = new JMSListenAndRespond();
         lis.consumeMessage(q);
        System.out.println("(type q to exit at any time...)\n");
        try {
          // Now just loop, waiting for messages until user types 'q' to quit
          commandBuffer = new InputStreamReader(System.in);
        while (!(command == 'q')) {
           try {
              command = (char)commandBuffer.read();
              System.out.println("Command: "+command);
              lis.stopListening();
            } catch (IOException e) {
              System.err.println("I/O Exception: ");
              e.printStackTrace();
           } //while
        } finally {
                lis.stopListening();
          lis.stopListening();
       public void stopListening() {
        try {
          if (jmsMessageConsumer != null) {
            jmsMessageConsumer.close();
          if (jmsSession != null) {
            jmsSession.close();
          if (jmsConnection != null) {
            jmsConnection.close();
        } catch (JMSException e) {
          System.err.println("Couldn't properly close all resources.\n");
          e.printStackTrace();
      private void prepareToConsumeMessage() {
        // create JMS connection, session, consumer and register listener - then start session
            try {
          // create connection
          jmsConnection = getJmsConnectionFactory().createConnection();
          // create session
          jmsSession =   jmsConnection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
          jmsMessageConsumer = jmsSession.createConsumer(getJmsDestination());
          // register a message listener (onMessage)
          jmsMessageConsumer.setMessageListener(this);
          // initiate connection - make sure to register your listener first or you might lose messages
          jmsConnection.start();
          System.out.println("\n...listening for message!\n");
        } catch (JMSException e) {
          System.err.println("Problem initializing JMS session");
          e.printStackTrace();
          System.exit(-1);
         * onMessage
         * The callback function invoked upon message reception
      public void onMessage(Message msg) {
        try {
          String msgText;
          if (msg instanceof TextMessage) {
            msgText = ((TextMessage)msg).getText();
            // this method expects a CSV string with the following makeup:
            // firstName,lastName,gender,birthdate,address,city,zipcode,state,insurancePolicyId
            String messageId = msg.getJMSMessageID();
          // code to process goes here.....
          } else {
            // if message is not a TextMessage, attempt a conversion to string
            System.out.println("\n** NEW MESSAGE (" + msg.getClass().getName() +
                               "):\n" +
                msg.toString());
        } catch (JMSException e) {
          e.printStackTrace();
      public void consumeMessage(JmsDataObject q ) {
        initializeJndiProperties(q);
        initializeJNDIandCF(q.getJmsQueue());
        prepareToConsumeMessage();
    import java.util.Properties;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.Destination;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public abstract class JMSQueueHandler {
      protected void initializeJNDIandCF(String destinationQueueName) {
        // initialize JNDI context and lookup connection factory and destination
        try {
          // Initialize JNDI context
          jndiContext = new InitialContext(jndiProperties);
        } catch (NamingException e) {
          e.printStackTrace();
        try {
          // lookup JMS connection factory in JNDI
          jmsConnectionFactory =
              (ConnectionFactory)jndiContext.lookup(jndiProperties.getProperty("factory.name"));
          // lookup JMS destination in JNDI
          jmsDestination = (Destination)jndiContext.lookup(destinationQueueName);
        } catch (NamingException e) {
          System.err.println("Problem during the JNDI lookup\n");
          e.printStackTrace();
          System.exit(-1);
      public void initializeJndiProperties(JmsDataObject qdo ) {
        // set JNDI properties
        jndiProperties.put("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory");
        jndiProperties.put("java.naming.provider.url", qdo.getUrl() );
       // jndiProperties.put("java.naming.security.principal", NAMING_PRINCIPAL);
        jndiProperties.put("java.naming.security.principal", qdo.getServerLogin() ) ;
        //  jndiProperties.put("java.naming.security.credentials", NAMING_CREDENTIAL);
        jndiProperties.put("java.naming.security.credentials", qdo.getServerPwd() );
        //jndiProperties.put("factory.name", JMS_CONNECTION_FACTORY);
        jndiProperties.put("factory.name", qdo.getJmsCF() );
      //protected static final String NAMING_PROVIDER_URL = "t3://localhost:7101";
    //protected static final String NAMING_PRINCIPAL = "weblogic";
    // protected static final String NAMING_CREDENTIAL = "welcome1";
    // protected static final String JMS_CONNECTION_FACTORY = "jms/patientsJmsCF";
    // protected static final String JMS_CONNECTION_FACTORY = "jms/TestConnectionFactory";
      ConnectionFactory jmsConnectionFactory = null;
      Destination jmsDestination = null;
      InitialContext jndiContext = null;
      Properties jndiProperties = new Properties();
      public void setJmsConnectionFactory(ConnectionFactory jmsConnectionFactory) {
        this.jmsConnectionFactory = jmsConnectionFactory;
      public ConnectionFactory getJmsConnectionFactory() {
        return jmsConnectionFactory;
      public void setJmsDestination(Destination jmsDestination) {
        this.jmsDestination = jmsDestination;
      public Destination getJmsDestination() {
        return jmsDestination;

    Thanks for the reply. There are no errors what so ever regarding MDB issues. Not in the weblogic / console logging, nor in the logging of the component itself.
    The MDB itself is setup to have 16 concurrent beans per component deployment. The component is clustered over 4 server instances. So there are quite some concurrent MDBs running. However since the messages get stuck for weeks eventhough the component only has bursts of messages to process, one would think that the the stuck messages would be processed whenever the component has some spare time (which it has a lot between the bursts).
    Therefor i doubt it has anything to do with too little MDBs running. But frankly I have no idea what's wrong.

  • NoInitialContextException when I try to lookup my ConnectionFactory

    Hello everyone,
    I'm now working on a small project using JMS, and I have installed the last version of JDK 6 Update 17 With J2EE.
    try{
         Context jndiContext = new InitialContext();
         connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/ConnectionFactory");
         queue = (Queue)jndiContext.lookup("jms/queue");
    }catch(NamingException exc){
         System.err.println("Lookup Object failed");
         exc.printStackTrace();
         System.exit(1);
    ... ... ...When I tried to run the program above, I got a NoInitialContextException at the line : Context jndiContext = new InitialContext() . The full error message is:
    {color:#0000ff}
    javax.naming.NoInitialContextException: Cannot instantiate class: org.exolab.jms
    .jndi.InitialContextFactory [Root exception is java.lang.ClassNotFoundException:
    org.exolab.jms.jndi.InitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    57)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:175)
    at SimpleMessageProducer.main(SimpleMessageProducer.java:49)
    Caused by: java.lang.ClassNotFoundException: org.exolab.jms.jndi.InitialContextF
    actory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
    a:46)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    54)
    ... 4 more{color}
    I have created a javax.jms.ConnectionFactory and a javax.jms.Queue in the Glassfish Admin Consle -> Resources -> JMS Resources -> Connection Factories / Destinations Resources, and I have also added the appserv-rt.jar and javaee.jar into CLASSPATH. But my program still doesn't work.
    I have tried to get my connection factory with the annotations @Resource, but it doesn't work either.
    Si I'm "lookup" someone who could debug this program for me,
    Greetings
    Edited by: WeepInSilence on Nov 8, 2009 8:57 AM
    Edited by: WeepInSilence on Nov 8, 2009 11:05 AM

    Hello esiuolyma,
    After reviewing your post, it sounds like the iPod is not recognized and that will not allow you to sync. I would recommend that you read these articles, they may be helpful in troubleshooting your issue.
    iPhone, iPad, or iPod not recognized in iTunes for Windows - Apple Support
    If you don't see your connected device in iTunes for Mac - Apple Support
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • How does JMS Destination relates to a Connection Factory ?

    Hello,
    I am new to JMS but have experience since 1995 with IBM MQseries, I like to understand how Connection Factories and Destination related to each other. I have looked at JMS documentation and seen the graphical representation but in MQ world we create a Queue Manger and a Queue under it. I have looke all over but can not explain this to myself.
    In Sun�s Java Application Server version 9, I have created a Connection Factory called �jms/ConnectionFactory_abc� and then have created a Destination called �jms/destination_abc� and successfully sent and received messages, what I do not understand is that there is no menu option in Sun�s web based screen to related the 2 together!! How do they relate? Do they related becuase of my program logic?
    What if you like to have same Destination names under 2 different Factories?
    ---------Code fragment without TRY/CATCH
    queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("jms/ConnectionFactory_abc ");
    queue = (Queue) jndiContext.lookup(�jms/destination_abc �);
    queueConnection = queueConnectionFactory.createQueueConnection();
    queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queueSender = queueSession.createSender(queue);
    message = queueSession.createTextMessage();
    message.setText(input);
    queueSender.send(message);
    queueConnection.close();
    Please advise
    Thank You.
    AA

    I'll have a stab at this one, but may not be 100% right. Hopefully someone will point out anything I've got wrong.
    A connection factory is used to obtain a connection to the JMS provider, which in the case of MQSeries is synonymous Queue Manager. The connection is used to initiate one or more conversations with the JMS provider / QM, which might include starting a new transactional session.
    The destinations (Queues or Topics) are objects hosted by the JMS provider, however your client can only access these objects after establishing a connection / session, since it is the connection / session which determines the protocols and parameters to be used.
    The JNDI lookups are just a way for your client to obtain a remote reference to the Connection Factory and Queue objects hosted by the JMS provider, without coupling your client with the underlying JMS implementation (i.e. MQSeries, JBossMQ, ActiveMQ etc). When these references are bound to the JNDI tree they are given names like "jms/ConnectionFactory_abc" and "jms/destination_abc", but are not related to each other. Attempting to bind two references with the same JNDI name (on the same JNDI server) will cause in an error. So while you can two identically named queues on separate queue managers, you would have to give them different JNDI names,
    Hope this helps,
    Steve

  • JMS Adapter: Dynamic DestinationName for third party queue

    Hello everbody!
    Is there a way to make the "DestinationName" of the JMS Adapter for a third party JMS provider dynamic somehow? Like using a jndi lookup for the queue name instead for hardcoding it into the wsdl?
    Thanks a lot.

    Hi all,
    Can any one guide me in the following requirements:
    Hello,
    can any one please help me in this issue:
    1) JMS Name and Description
    2) Parameter Values for Provider Context Factory, Connection Factory, and Default Provider URL.
    Please note that the Agile PLM system fills in the fields with server-specific defaults but we must validate they are accurate.
    3) User Name and Password to access the queue
    1.1) JMS Name : its an queue name
    Description : Queue/ Topic with JNDI name
    2.1) Context factory :
    what is it?
    how to create it and where to create.
    2.2)connection factory: connection factory name and JNDI.
    2.3) how to get the Default URL from web-logic.
    3.2) User name/ password : xxxxxxxxx/abcd00000. this can be set from security realms by creating the user and and assigning that user to the queue and policies.
    can any one clarify my doubts in it.
    Anil

  • Configure/Access remote Message Queue (Open MQ)

    Hi,
    I am new to JMS and Message Queue. I have installed Sun's Open Message Queue on my system.I have created ObjectStore and Destination(Queue) and using java program to insert and fetch messages.
    Following are the details:
    1. Created ObjectStore MyObjectStore with following properties:-
    java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
    java.naming.provider.url=file:///c:/tmp
    2. Created ConnectionFactory MyConnectionFactory and Destination MyQueue
    3. Code to access above queue:
    Hashtable env;
        Context     ctx = null;
        env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
        env.put(Context.PROVIDER_URL, "file:///c:/tmp");
        ConnectionFactory cf=(javax.jms.ConnectionFactory) ctx.lookup("MyConnectionFactory");
        Queue queue=(javax.jms.Queue)ctx.lookup("MyQueue");
        Connection connection = cf.createConnection();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer msgProducer = session.createProducer(queue);
        MessageConsumer msgConsumer = session.createConsumer(queue);
        ....................My problem is that I am able to access Message Queue on local machine only. I don't know how i can configure my MQ to be accessed on network or/and how to look up for MQ from a remote machine in network.
    Can anybody help me on this.
    Regards
    Edited by: Arpit.Purohit on Apr 8, 2009 4:49 AM
    Edited by: Arpit.Purohit on Apr 8, 2009 4:49 AM

    Arpit,
    Yes, this is because you have chosen to use com.sun.jndi.fscontext.RefFSContextFactory as the JNDI provider in which to store your destination and connection factory objects.
    The Sun Java System Message Queue 4.3 Administration Guide has a section [File-System Object Stores|http://docs.sun.com/app/docs/doc/820-6740/aeogx?a=view] about this:
    +"Message Queue ... supports the use of a directory in the local file system as an object store for administered objects. While this approach is not recommended for production systems, it has the advantage of being very easy to use in development environments. Note, however, that for a directory to be used as a centralized object store for clients deployed across multiple computer nodes, all of those clients must have access to the directory. In addition, any user with access to the directory can use Message Queue administration tools to create and manage administered objects"+
    So if you place your JNDI store in a shared directory visible to other machines rather than C:/tmp you will be able to access it from other machines.
    The ideal solution is to use an LDAP JNDI provider. See the section [LDAP Server Object Stores|http://docs.sun.com/app/docs/doc/820-6740/aeogw?a=view] in the Administration Guide.
    Note that this issue relates to the administered objects used by MQ only. The MQ broker itself will be available from anywhere on the network and the messages themselves will stored in the broker's own message store.
    Nigel

Maybe you are looking for