|
From: Eugene K. <eu...@md...> - 2005-11-23 14:47:56
|
There is nothing wrong to use MDB as a listener. You can delegate all the processing to Spring-based classes same way as from Spring-based listener. regards, Eugene shifei luo wrote: > My dear Spring Community, As far as I know, Spring 1.3 will provide JMS > Listener support asynchronously. > But in WebSphere 6.0 Web Container, this isn't possible for the > following reason. > Can't Use MessageListeners in J2EE > > posted by Bobby Woolf > Permalink > > Here's an interesting conflict between JMS and J2EE that I just > rediscovered: > > You can't run an implementor of MessageListener in a J2EE container. > J2EE 1.3 says not to do it in the EJB container. J2EE 1.4 says not to do > it in the Web container either. Basically, you can't use it in any > container that controls thread creation, which is any container except > an application client container. > > WAS 5 and 6 don't allow MessageListeners to be used in either container. > When you try, you get an error like this: > > > > javax.jms.IllegalStateException: Method setMessageListener not permitted > at > com.ibm.ejs.jms.JMSCMUtils.methodNotPermittedException(JMSCMUtils.java:202) > at > com.ibm.ejs.jms.JMSMessageConsumerHandle.setMessageListener(JMSMessageConsumerHandle.java:193) > at MyMessageListenerImpl.connect(MyMessageListenerImpl.java:39) > . . . > > > So WAS doesn't actually prevent you from deploying a class that > implements MessageListener, but when you try to run your code, WAS > prevents the MessageConsumer.setMessageListener(MessageListener) method > from running by throwing an IllegalStateException. For details, see IBM > WMQ FAQ answer #92 and IBM Technote #1114239. > > So when you get this error, the problem isn't a bug in your code, it's > your entire approach. In a nutshell, if you want to run a > MessageListener in J2EE, don't implement a MessageListener, implement a > (can you guess?) messsage-driven bean (the JMS kind, which implements > MessageListener). And if you don't like using EJBs? Get used to it. MDBs > work in J2EE; MessageListeners don't. > > (from Bobby Woolf Blog) > > http://www-128.ibm.com/developerworks/blogs/dw_blog_comments.jspa?blog=392&entry=71861 > <http://www-128.ibm.com/developerworks/blogs/dw_blog_comments.jspa?blog=392&entry=71861> > > Because my current project may use WebSphere 6.0,and it must listener > messages from Web Container asynchronously, So the > answer is urgent to me. By the way, we have not use MDB to listener > messages. > > Do Spring 1.3 plan providing workaround for this or some other solutions? > > thx. |