• Post Reply Bookmark Topic Watch Topic
  • New Topic

jms puts / get within a mdb  RSS feed

 
Sreenivas Mangasandra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

i am trying to put and get messages within a mdb(WAS Scenario). Well ofcourse the mdb gets messages when the onMessage is called. and hence it would not be a problem to get a loop of msgs. but i would like to know how can i implement a put. is it within an ejbCreate() call.

i have tried it like this....

iCtx = new InitialContext();
outMessage = null;

factory = JMSPut.getConnectionFactoryFromJNDI(iCtx,"jms/QCF100" );
ioQueue= JMSPut.getQueueFromJNDI(iCtx,"jms/Q100");

connection = factory.createQueueConnection();
connection.start();

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

queueProducer = session.createSender(ioQueue);

outMessage.setText("This is a test String");

queueProducer.send(outMessage);
}
catch( JMSException jmsException )
{
System.out.println("\n[MDB] JMS Exception Occured.");
}
catch( NamingException nameException )
{
System.out.println("\n[MDB] Unable to retrieve the QCF object from JNDI.");
}


but there a lot of errors like:

12/16/04 11:04:43:234 CET] 7970e914 SystemOut O MDB100 ejbCreate() called
[12/16/04 11:04:43:266 CET] 7970e914 ServerSession W WMSG0031E: Exception processing JMS Message for MDB someBean, JMSDestination jms/Q100 : java.lang.NullPointerException
at com.ibm.mq.jms.MQSession.run(MQSession.java:1011)
at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:924)
at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:740)
at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:525)
at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:492)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:373)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)

[12/16/04 11:04:43:281 CET] 7970e914 ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "onMessage" on bean "BeanId(someMDB#someMDBEJB.jar#someBean, null)". Exception data: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:373)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
Caused by: java.lang.NullPointerException
at com.ibm.mq.jms.MQSession.run(MQSession.java:1011)
at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:924)
at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:740)
at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:525)
at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:492)
... 8 more

[12/16/04 11:04:43:297 CET] 7970e914 LocalTranCoor E WLTC0017E: Resources rolled back due to setRollbackOnly() being called.





i would be thankful, if anyone can suggesst or give links related to it.

srinu
 
Sreenivas Mangasandra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Well for further references. i could solve the problem. The basic ideas can be Two methods. one is to static variables in the mdb to create a loop counter for a specified loop. The next one is to include a kind of header in the message itself, to generate in this format and extract the counter values, size of the message and time stamp if necessary.

Srinu.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!