EJBã³ã³ããã¼ãWebã³ã³ããã¼å ã§ç®¡çãããJMSæ¥ç¶ããåæã«è¤æ°ã®Sessionãçæã§ããªã
以ä¸ã®æ¡ä»¶ãæºããã¨JBoss Messaging + Spring MDPã®ç°å¢ã§ä»¥ä¸ã®ä¾å¤ã¨ãªãã¾ãã
- java:/JmsXAããXA対å¿ï¼JCAã®ãªã½ã¼ã¹ã¢ããã¿ã¼çµç±ï¼ã®æ¥ç¶ãã¡ã¯ããªã使ç¨
- concurrencyå±æ§ã2以ä¸ã«è¨å®
- cacheå±æ§ãsession以ä¸ã«è¨å®
javax.jms.JMSException: Could not create a session: javax.jms.IllegalStateException: Only allowed one session per connection. See the J2EE spec, e.g. J2EE1.4 Section 6.6 at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.allocateConnection(JmsSessionFactoryImpl.java:426) at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.createSession(JmsSessionFactoryImpl.java:374) at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:196) at org.springframework.jms.listener.DefaultMessageListenerContainer.access$12(DefaultMessageListenerContainer.java:1) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.initResourcesIfNecessary(DefaultMessageListenerContainer.java:1078) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1057) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) at org.springframework.jca.work.DelegatingWork.run(DelegatingWork.java:57) at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:205) at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
å®éã«JavaEEã®ä»æ§æ¸ã®6.6ç¯ã«ã¯ä»¥ä¸ã®è¨è¿°ãããã¾ãã
Application components in the web and EJB containers must not attempt to create more than one active (not closed) Session object per connection. An attempt to use the Connection objectâs createSession method when an active Session object exists for that connection should be prohibited by the container. The container may throw a JMSException if the application component violates this restriction. Application client containers must support the creation of multiple sessions for each connection.
ã¤ã¾ããEJBãWebã³ã³ããã¼å
ã®ã³ã³ãã¼ãã³ããåä¸ã®JMSæ¥ç¶ããåæã«è¤æ°ã®ã¢ã¯ãã£ããªSessionãä½æã§ããªãã¨ãããã¨ã§ãããï¼å¤é¨ã®ã¯ã©ã¤ã¢ã³ãã®å ´åã¯éã«è¤æ°ã®æ¥ç¶ãä½æã§ããªãã¦ã¯ãªããªãããã§ããï¼
ãããã£ã¦ã以ä¸ã®XA対å¿ã®ç®¡çããããã¥ã¼ã«å¯¾ããJMSæ¥ç¶ã使ç¨ããå ´åã¯ä»¥ä¸ã®ããããã®è¨å®ã«ããå¿
è¦ãããã¾ãã
<jms:listener-container concurrency="1" cache="consumer" ... > <jms:listener-container concurrency="2以ä¸" cache="none" ... >
ãã ããé常ãããã¯ã®å ´åã¯åæã«åãã¡ãã»ã¼ã¸ãåä¿¡ãã¦ãå°ãã®ã¨ãsubscriberã¯å¸¸ã«ã¢ã¯ãã£ãã§ãªãã¨åä¿¡æ¼ããçºçãããããåè
ã®è¨å®ããåããã¾ããã
ãªãããã®åé¡ã¯Springåºæã®åé¡ã§ã¯ãªãã¦ãJavaEEã®ä»æ§ã®åé¡ãªã®ã§Seamã§ãçºçããã±ã¼ã¹ãããããã§ããrarãã¡ã¤ã«ã®è¨å®ã«ãããJavaEEã®ä»æ§ã«å³å¯ã«å¾ããã«è¤æ°ã®JMS Sessionã®çæãå¯è½ã«ãããã¨ãå¯è½ãªããã§ãã
http://seamframework.org/Community/ManagedTopicPublisherJavaxjmsIllegalStateExceptionOnlyAllowedOneSessionPerConnection