[jboss-user] [JBoss Messaging] - ConcurrentModificationException when setup connection with s
tony9427
do-not-reply at jboss.com
Tue Dec 4 23:01:38 EST 2007
Purpose: create 20 THread ,each create connection to JMS.
Sometimes it's OK but occassionally it will throw ConcurrentModificationException .....
Please help to have a look
| public class JRouterJmsHandler {
| private static Logger logger = Logger.getLogger(JRouterJmsHandler.class.getName());
| RouterInitializer ri;
| int ThreadPoolSize =20;
|
| public JRouterJmsHandler(RouterInitializer ri){
| this.ri = ri;
| }
|
| public void handle(){
| ExecutorService exec = Executors.newFixedThreadPool(ThreadPoolSize);
| for(int i = 0;i<ThreadPoolSize;i++){
| RouterJmsProcesser processer = new RouterJmsProcesser(ri);
| exec.execute(processer);
| }
|
| }
| }
public class RouterJmsProcesser implements Runnable{
| .....
| ....
|
| public void run() {
| if(setupJMS()){
| logger.info("setup JMS environment sucessfully");
| doJmsRoute();
| }else{
| logger.warn(" setup JMS environment error ......");
| }
|
| }
|
| /**
| * @return boolean -> if jms object setup ok
| *
| */
| public synchronized boolean setupJMS() {
| try {
| this.serviceFactory = new ServiceFactory("/ConnectionFactory",new JrouterExceptionListener());
| String inQueue = ri.getInoutMap().get(Constants.CONF_XMS_FW_QUEUEIN);
| this.queue = QueueService.getQueue(inQueue);
| this.receiver = serviceFactory.createReceiver(queue);
|
| String strOutQueue = ri.getInoutMap().get(Constants.CONF_XMS_FW_QUEUEOUT);
| this.outputQueueu = QueueService.getQueue(strOutQueue);
| this.sender = serviceFactory.createSender(outputQueueu);
| // to judge if jboss connection is ok or not
| return true;
|
| } catch (Exception e) {
| logger.error("Error setting up JMS", e);
| try{
| serviceFactory.destroy();
| }catch (Exception ignored){
| // Pointless
| }
| return false;
| }
| }
|
| }
Error information:
java.util.ConcurrentModificationException
| at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:617)
| at java.util.LinkedList$ListItr.next(LinkedList.java:552)
| at java.util.AbstractCollection.toString(AbstractCollection.java:453)
| at java.lang.String.valueOf(String.java:2615)
| at java.lang.StringBuffer.append(StringBuffer.java:220)
| at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.initPool(MicroSocketClientInvoker.java:715)
| at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.handleConnect(MicroSocketClientInvoker.java:450)
| at org.jboss.remoting.transport.bisocket.BisocketClientInvoker.handleConnect(BisocketClientInvoker.java:283)
| at org.jboss.remoting.MicroRemoteClientInvoker.connect(MicroRemoteClientInvoker.java:242)
| at org.jboss.remoting.ConnectionValidator.start(ConnectionValidator.java:301)
| at org.jboss.remoting.ConnectionValidator.addConnectionListener(ConnectionValidator.java:228)
| at org.jboss.remoting.Client.addConnectionListener(Client.java:367)
| at org.jboss.remoting.Client.addConnectionListener(Client.java:339)
| at org.jboss.jms.client.remoting.JMSRemotingConnection.addConnectionListener(JMSRemotingConnection.java:378)
| at org.jboss.jms.client.container.StateCreationAspect.handleCreateConnectionDelegate(StateCreationAspect.java:103)
| at org.jboss.aop.advice.org.jboss.jms.client.container.StateCreationAspect0.invoke(StateCreationAspect0.java)
| at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.invokeNext(ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.java)
| at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.createConnectionDelegate(ClientConnectionFactoryDelegate.java)
| at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:205)
| at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:87)
| at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:82)
| at net.netm.framework.messaging.jms.ServiceFactory.<init>(Unknown Source)
| at net.netm.jrouter.RouterJmsProcesser.setupJMS(RouterJmsProcesser.java:136)
| at net.netm.jrouter.RouterJmsProcesser.run(RouterJmsProcesser.java:51)
| at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
| at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
| at java.lang.Thread.run(Thread.java:595)
Please help!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110411#4110411
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110411
More information about the jboss-user
mailing list