3 Replies Latest reply on Apr 10, 2007 10:33 AM by cresny

    Problem sending message from container using Managed connect

    cresny

      We have a JBoss 4.0.5.GA server instance (server A) communicating with a non-clustered JBoss Messaging instance (server B) via scoped deployment and modified JCA datasource descriptor as outlined in:

      http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossMessagingUser_Enabling_access_to_remote_JBoss_Messaging_instance

      All MDBs in server A deploy and pick up messages fine. The problem we have is in sending messages from Server A using a managed connection factory.

      With the following code, messages appear to be sent but do not show up in the destination:

      InitialContext ic = new InitialContext();
      cf = (ConnectionFactory)ic.lookup("java:/JmsXA");
      Connection connection = cf.createConnection();
      connection.start();
      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      ic.close();
      Queue queue = session.createQueue("testQueue");
      producer = session.createProducer(queue);
      tm = session.createTextMessage(txt);
      producer.send(tm);

      If we tail the log on server B (JBM), we do see the session.start() as well as session.close() on subsequent runs. I assume the session is being cached. However, even though there are no errors, we see no messages in the queue.

      The same code *will* send messages properly if we get the ConnectionFactory with a hack:

      InitialContext ic = new InitialContext();
      Object object = ic.lookup("java:/DefaultJMSProvider");
      ic.close();
      InitialContext ic2 = (InitialContext)object.getClass().getMethod("getInitialContext", null).invoke(object, null);
      ConnectionFactory cf = (ConnectionFactory) ic2.lookup("XAConnectionFactory");
      ic2.close();

      Is there a way to send messages from within the container with a managed connection factory?










        • 1. Re: Problem sending message from container using Managed con

          By any chance do you have JBM installed on the local server (A) too?

          • 2. Re: Problem sending message from container using Managed con

            Also, the JmsXA will return a XAConnectionFactory. Are you starting a Tx but not committing?

            • 3. Re: Problem sending message from container using Managed con
              cresny

              Server (A) does not have any messaging installed locally, just the resource adapter with jms-ds.xml configured to point to Server (B).

              We get the same behavior when we connect and send via java:/JmsXA, whether from a Session bean with transaction REQUIRED or SUPPORTS, or from an MBean; it's consistently a silent failure and no messages get to the Destination, regardless of transaction scope. What's frustrating is it seems like it works, but it doesn't.

              I'm wondering if this is just our unfamiliarity with JBM's Server Peer architecture. I mean, *must* we have JBM installed on Server (A), perhaps with distributed queues? The way we current have it is that JBM is a messaging-only node or cluster. Server (A) would be just one of several clients - but in this case it is a container client, while others are just simple processes. What we want is managed remote connections, in our case more for performance concerns than for the XA (We could alternatively use Spring's JMSTemplate, which does pool sessions, but JBM's documentation specifically warns against it).

              Meanwhile, I've have difficulty finding any documentation or examples of *sending* messages from a remote container; all the container examples seem to be of consuming with MDBs.