Sean,
  it works very well so i post it here.
 
  thank u again.
 
  And wish it would help others.
 
regards
   lee
 
/************** sean's mail *************************/
 
Lee,

Here is a program, based on your program that works for me. I had to
re-arrange a few things in your program.

You will need to change the JNDI details to suit your environment.

I think the main thing wrong was that the connection.start() has to
occur
after everything else has been set up.

Hope this helps. If it works, please post to the jython list.

Sean

-------------------------
#jmsP2pReceiver.py

from java.util import Properties
from javax.jms import MessageListener, Session
from javax.naming import Context, InitialContext

class textListener(MessageListener):
         def onMessage(self,message):
                 msg = message.getText()
                 print "Got a message", msg


#look up connection factory and queue in jndi
properties = Properties()
properties[Context.PROVIDER_URL] = "file:///C:/temp"
properties[Context.INITIAL_CONTEXT_FACTORY] =
"com.sun.jndi.fscontext.RefFSContextFactory"

initialContext = InitialContext(properties)

connectionFactory = initialContext.lookup("MyQueueConnectionFactory")
queue = initialContext.lookup("PMQ1")
initialContext.close()

#create a connection
connection = connectionFactory.createQueueConnection()

#create session
session = connection.createQueueSession(0, Session.AUTO_ACKNOWLEDGE)

#create receiver
receiver = session.createReceiver(queue)

#register listener
listener = textListener()
receiver.messageListener = listener

# start
connection.start()
x = raw_input ("Listening. Press a key to stop.\n")

connection.close()



Do You Yahoo!?
暑期大片齐聚雅虎通 网络摄像头+雅虎通调频收音机等你来拿