Here is the code that can help you
Code:
public void sendMessage() throws JMSException, NamingException, InterruptedException (
/ / Rcupration context
Properties test = new Properties(); test.could(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); test.could(Context.URL_PKG_PREFIXES, "jboss.naming: org.jnp.interfaces"); test.could(Context.PROVIDER_URL, "JNP: / / localhost: 1099"); InitialContext temp = new javax.naming.InitialContext(test),
/ / institution Connection and rcupration a director at the tail target
QueueConnectionFactory queueCnxFactory = (QueueConnectionFactory)temp.lookup("ConnectionFactory"); QueueConnection que = queueCnxFactory.createQueueConnection(); queses queses = que.createQueueSession(false, queses.AUTO_ACKNOWLEDGE); quesmd quesmd = queses.createSender((Queue)temp.lookup("queue / MDBReceiveQueue")); que.start(); TextMessage tms = queses.createTextMessage(); tms.setText("Hello"); quesmd.send(tms);
/ / Closing sessions and connections
quesmd.close(); que.stop(); queses.close(); que.close();
)
Bookmarks