0 Replies Latest reply on Feb 28, 2007 10:31 AM by Andrew Gilmour

    Getting a JMS producer to send to remote queue

    Andrew Gilmour Newbie

      Hi,

      I have a local InitialContext() and have used this to create a local QueueConnection, QueueSession, and local consumer(QueueReceiver) to receive messages on a local receive Queue. My local producer(QueueSender) is to send to a remote destination but the jndi lookup is failing as (I think) the jndi name has no information about the location of the remote server.

      My code is this:

      QueueSender sender = localQueueSession.createSender(remoteQueue);


      And I get the error:

      (javax.jms.InvalidDestinationException: This destination does not exist! QUEUE.remotequeuename)


      The remoteQueue is created using a correctly configured remoteIntialContext() different to my local initialContext(). From that remoteInitialContext() I created a remote QueueConnection, QueueSession and used the remoteInitialContext() to lookup() the remote destination(queue), which I pass to the LOCAL producer.

      The only way I can get it to work is to do this:

      QueueSender sender = remoteQueueSession.createSender(remoteQueue);


      but as far as my understanding goes that is creating a producer on the remote server, not the local server. Then to send the message I first create the message remotely,

      ObjectMessage om = remoteQueueSession.createObjectMessage(message);


      and then:

      sender.send(om);


      which sends the message to the remote destination (remoteQueue) which pops my MDB.

      I may be wrong but this seems like the wrong way to do it(all remotely) as the local producer must surely be able to send to a remote destination.

      Any help would be much appreciated!

      Andy