aspose file tools*
The moose likes Java in General and the fly likes java code to send message to JMS queue with out JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java code to send message to JMS queue with out JNDI" Watch "java code to send message to JMS queue with out JNDI" New topic
Author

java code to send message to JMS queue with out JNDI

Ravindra Talari
Greenhorn

Joined: Dec 04, 2012
Posts: 1
Hi Everyone,

Actually I am working on TIBCO, One of our partner does not has TIBCO environment, He wants to send messages to our JMS server. We are thinking that we can write java code to send messages to JMS queue. I have written below java code, I am getting the below error. Please suggest ..thanks in advance.

Error:
Dec 5, 2012 12:16:27 PM com.sun.messaging.jmq.jmsclient.ExceptionHandler logCaughtException
WARNING: [I500]: Caught JVM Exception: java.net.SocketException: Connection reset
Exception in thread "main" com.sun.messaging.jms.JMSException: [C4000]: Packet acknowledge failed. user=empty/blank, broker=localhost:7222

Code:

ConnectionFactory connFactory =new com.sun.messaging.ConnectionFactory();
connFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqAddressList,new String("mqtcp://localhost:7222/"));
//connFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqDefaultUsername,"");
//connFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqDefaultPassword,"");
connFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqDefaultUsername,"");
connFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqDefaultPassword,"");
//connFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqSSLIsHostTrusted,"true");

// create a queue connection
QueueConnection queueConn = connFactory.createQueueConnection();

// create a queue session
QueueSession queueSession = queueConn.createQueueSession(false,
Session.DUPS_OK_ACKNOWLEDGE);

// create a queue sender

QueueSender queueSender = queueSession.createSender((Queue)(new com.sun.messaging.Queue("citi.gts.na.teis_162052.GPOS.ndm.sender")));
//queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

// create a simple message to say "Hello"
TextMessage message = queueSession.createTextMessage("Hello");

// send the message
queueSender.send(message);

// print what we did
//System.out.println("sent: " + message.getText());

// close the queue connection
queueConn.close();
----------------------------------
Even I tried to create like below

MQQueueConnectionFactory connFactory=new com.ibm.mq.jms.MQQueueConnectionFactory();
connFactory.setHostName("10.226.186.42");
connFactory.setPort(7222);
//connFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);

I am getting the below error.

xception in thread "main" java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

Have a look here:
https://www.ibm.com/developerworks/forums/message.jspa?messageID=14640542


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java code to send message to JMS queue with out JNDI
 
Similar Threads
jdeveloper look up error for jms
Queue Connection
Separating JMS Producer/Consumer on JBoss 4.0.2
Could not create JNDI API context: javax.naming.CommunicationException: Cannot connect to ORB
javax.naming.NoInitialContextException