You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ilango_g <il...@yahoo.com> on 2008/10/19 03:26:43 UTC
problem in doProcess() method in a servlet that posts messages
I have written a servlet that will post messages to queue via a Session Bean
Facade.
Inside the doProcess method in this servlet,
I have the following code:
try {
InitialContext ctx = new InitialContext();
queue = (Queue) ctx.lookup("queue/mdb");
QueueConnectionFactory factory =
(QueueConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createQueueConnection();
session =
connection.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
messageProducer = session.createProducer(queue);
ObjectMessage message = session.createObjectMessage();
// here we create a NewsEntity, that will be sent in JMS message
QueueingEntity e = new QueueingEntity();
e.setTitle(title);
e.setBody(body);
message.setObject(e);
messageProducer.send(message);
messageProducer.close();
connection.close();
response.sendRedirect("ListMessages");
/*
* Context ctx = new InitialContext();
ConnectionFactory connectionFactory =
(ConnectionFactory)ctx.lookup("jms/tConnectionFactory");
Queue queue = (Queue)ctx.lookup("jms/tQueue");
javax.jms.Connection connection =
connectionFactory.createConnection();
javax.jms.Session session =
connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage message = session.createTextMessage();
message.setText(request.getParameter("message"));
System.out.println( "It come from Servlet:"+ message.getText());
messageProducer.send(message);
*/
}
The IDE (Netbeans is telling me the following:
incompatible types:
found: javax.jms.QueueSession.CreateProducer
required:javax.jms.MessageProducer
I am not able to figure this out, even though it looks like a trivial Java
problem.
Any suggestions are appreciated.
thanks
--
View this message in context: http://www.nabble.com/problem-in-doProcess%28%29-method-in-a-servlet-that-posts-messages-tp20052341p20052341.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.