Hi,

I have written the following code to pass a xml to the queue.,

package com.landg.pce.jms;

import java.io.FileInputStream;

//import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
//import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.springframework.beans.factory.InitializingBean ;
import org.springframework.jms.core.JmsTemplate102;
import org.springframework.jms.core.MessageCreator;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import javax.jms.QueueConnection;
import javax.jms.QueueSession;

/**
* Simply sends a xml message to the JMS queue at application context startup
* time.
*
* @author Xansa UK
*/
public class MessageProducer implements InitializingBean {
// private Session session;
private MQQueueConnectionFactory connectionFactory;
private Queue queue;
JmsTemplate102 template;
/**
* Initial Constructor.
*
*/
public MessageProducer() {
try {
InitialContext ctx = new InitialContext();
connectionFactory = new MQQueueConnectionFactory();
String queueManager = "QM_zzduk4v3nn1j";
connectionFactory.setQueueManager(queueManager);

QueueConnection connection = connectionFactory.createQueueConnection();

QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

String qcf = "connectionFactory";
ctx.bind(qcf, connectionFactory);

String queueName = "pce";
Queue ioQueue = session.createQueue(queueName);

String qname = "JMSQueue";
ctx.bind(qname, ioQueue);

template = new JmsTemplate102(connectionFactory, false);
}
catch (NamingException e) {
e.printStackTrace();
}
catch (JMSException je) {
je.printStackTrace();
}
}

/**
*
* @param queue
* Queue
*/
public void setQueue(final Queue queue) {
this.queue = queue;
}

/**
*
* @param template
* JmsTemplate102
*/
public void setTemplate(final JmsTemplate102 template) {
this.template = template;
}

/**
*
* @return template
*/
public JmsTemplate102 getTemplate() {
return template;
}

/**
*
* @see org.springframework.beans.factory.InitializingBean #afterPropertiesSet()
*/
public void sendMessage() throws Exception {

/*
* Pass the request XML to the queue to be picked up by the MDB and
* process it.
*/
System.out.println("Inside After Properties set");
String xmlFile = new String("C:\\PceInstall\\request.xml");
FileInputStream fis = new FileInputStream(xmlFile);
System.out.println("Read XML");
int i = fis.available();
byte[] b = new byte[i];
fis.read(b);
final String xml = new String(b);
System.out.println("Created String");

template.send(queue, new MessageCreator() {
public Message createMessage(final Session session) throws JMSException {
System.out.println("Inside Create Message");
TextMessage tm = session.createTextMessage(xml);
System.out.println(tm.toString());
return tm;
}
});
}

/**
*
* @see org.springframework.beans.factory.InitializingBean #afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
}
}
Can anyone tell me how to configure the application context.

Thanks and Regards,

RK