Am trying to create a standalone java application to send message to different application using JMS. My reference code uses queueConnectionFactory and all connection parameters are configured in WAS server and retrieved using JNDI. But I cannot use server in my standalone application. In this case, how can I get or connect to the same host, port and queue without using JNDI.
Below is the code I have tried so far
try {
//Set connection factory
ActiveMQConnectionFacotry connectionFactory = new ActiveMQConnectionFactory("");
//create connection with connection factory
Connection connection = connectionFactory.createConnection();
connection.start();
//create session from connection
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//create queue from session
Destination destination = session.createQueue("sample.Queuename");
//create messageProducer
MessageProducer producer = session.createProducer(destination);
My reference code
//@Resource
private static Queue queue;
private QueueConnection con;
private QueueSession session;
private QueueSender sender;
private static InitialContext ctx;
private static JAXBContext jaxb;
private static IBwLogContext logContext = BwLogContextFactory.create();
static{
try {
ctx = new InitialContext();
queue = (Queue) ctx.lookup("jms/sampleJNDI1");
qcf = (QueueConnectionFactory) ctx.lookup("jms/sampleJNDI2");
JMS configuration is server for jms/sampleJNDI2
Now how do I connect to same xxx,yyy,zzz without server. Can we put these details in properties file and use them. If so, how to do it or is there any other way. I have hard coded queue name copying from the server. But stuck with ConnectionFactory.
Thanks in advance
