No matter from where you want to send JMS messages, the code is pretty much like in the following client. I have copied a simple client, hope you can figure out from this.
package j2eepatterns.tests;
/**
* <p>Title: </p>
* <p>Description: This is the client class for the MessageFacade</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author Sergiu Truta
* @version 1.0
*/
import j2eepatterns.businessdelegate.dto.*;
import javax.naming.*;
import javax.jms.*;
import java.util.*;
import java.text.*;
import java.math.BigDecimal;
public class TestPostMessageMDB {
public static void main(
String[] args){
QueueConnectionFactory queueConFactory = null;
QueueConnection queueCon = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender qsend = null;
ObjectMessage objectMessage = null;
java.util.Properties p = new java.util.Properties();
try{
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
p.put(Context.PROVIDER_URL,"localhost:1099");
p.put("java.naming.factory.url.pkgs","org.jboss.naming

rg.jnp.interfaces");
InitialContext iContext = new InitialContext(p);
queueConFactory = (QueueConnectionFactory)iContext.lookup( "ConnectionFactory" );
queue = (Queue)iContext.lookup("queue/DLQ");
}catch(NamingException e){
System.out.println("JNDI look up failed: " + e.toString());
}
try{
queueCon = queueConFactory.createQueueConnection();
queueSession = queueCon.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
qsend = queueSession.createSender(queue);
MessageDTO messageDTO = new MessageDTO();
messageDTO.setTitle("What can you guys say about CMP versus BMP?");
messageDTO.setDescription("Read Ed Roman's EJB 2nd edition.You can find it on theserverside.com");
messageDTO.setOwner(new UserDTO(new BigDecimal(29)));
messageDTO.setRootMessage(new Double(97));
//this is an object message that should not get to our PostMessageMDB
objectMessage = queueSession.createObjectMessage("this object message should not reach the repository!");
qsend.send(objectMessage);
//this is an object message that should get to our PostMessageMDB
objectMessage = queueSession.createObjectMessage(messageDTO);
qsend.send(objectMessage);
//this is a text message that should not get to our PostMessageMDB
TextMessage tm = null;
tm = queueSession.createTextMessage();
tm.setText("This is a text");
qsend.send(tm);
}catch(JMSException e){
System.out.println("JMS exception occurrred : " + e.toString());
}finally{
if(queueCon != null){
try{
queueCon.close();
}catch (JMSException e){
}
}
}
}
}
Cheers
