[jboss-user] [Messaging, JMS & JBossMQ] - check if message is in queue
argol1278
do-not-reply at jboss.com
Thu Jul 17 15:46:00 EDT 2008
hi all
My message driven bean can't reciver message and i wont to check where i made mistake in sending or in MDB
1) i am sending message form stateless bean could be there problem?
2) i must set this method setMessageListener() could it be constructor?
----------------------------------------
| InitialContext ctx = new InitialContext();
| QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
|
| Queue que = (Queue)ctx.lookup("queue/A");
|
|
| QueueConnection connection = factory.createQueueConnection();
|
|
| QueueSession session = connection.createQueueSession(false, javax.jms.QueueSession.AUTO_ACKNOWLEDGE);
|
| MessageProducer producer = session.createProducer(que);
|
|
| MapMessage mapMsg = session.createMapMessage();
| mapMsg.setString("subject", subject);
| mapMsg.setString("content", content);
| mapMsg.setString("mimi", mime);
| mapMsg.setString("mailTo", mailTo);
|
| System.out.println("EJB");
|
| producer.send(mapMsg);
|
|
--------------------------------------------
***********************************
***********************************
-----------------------------------------------
| @MessageDriven(activationConfig =
| {
| @ActivationConfigProperty(propertyName="destinationType",
| propertyValue="javax.jms.Queue"),
| @ActivationConfigProperty(propertyName="destination",
| propertyValue="queue/A")
| })
| public class NotificationJms implements MessageListener {
|
| public NotificationJms() {
|
| try{
|
| System.out.println("JMS KONSTRUKTOR");
|
| InitialContext ctx = new InitialContext();
| QueueConnectionFactory factory =
| (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
| Queue que = (Queue)ctx.lookup("queue/A");
|
|
| QueueSession session = connection.createQueueSession(false, javax.jms.QueueSession.AUTO_ACKNOWLEDGE);
|
| MessageConsumer cons = session.createConsumer(que);
| cons.setMessageListener(this);
|
| connection.start();
|
|
| }catch(NamingException e){} catch (JMSException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
|
|
|
| public void onMessage(Message message) {
|
| System.out.println("JMS onMessage METODA");
|
| MapMessage mapMsg = (MapMessage)message;
| try {
|
|
| System.out.println(mapMsg.getStringProperty("subject")+
| mapMsg.getStringProperty("content")+
| mapMsg.getStringProperty("mimi")+
| mapMsg.getStringProperty("mailTo"));
|
| } catch (JMSException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165183#4165183
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165183
More information about the jboss-user
mailing list