qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oggie <gog...@gmail.com>
Subject Re: java broker with jms and point to point
Date Wed, 26 Sep 2012 12:58:54 GMT
I'm using spring jms and now that we've straightened out the queue issue,
it's now throwing an exception. It wasn't before when it was creating the
temp queues. 

What I'm doing on the producer side is kicking off multiple threads and
passing a org.springframework.jms.core.JmsTemplate to each of those threads.
Then each thread uses that JmsTemplate to send a message to the queue.

Here's the exception:

 Uncategorized exception occured during JMS processing; nested exception is
javax.jms.JMSException: Error creating connection: BrokerDetails details
required for connection.
        at
org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
        at
org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
        at
org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:469)
        at
org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:534)
        at
org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:526)
        at
datacollector.CPEDeviceCollector.sendMessage(CPEDeviceCollector.java:129)
        at datacollector.DeviceCollector.run(DeviceCollector.java:64)
        at java.lang.Thread.run(Thread.java:722)
Caused by: javax.jms.JMSException: Error creating connection: BrokerDetails
details required for connection.
        at
org.apache.qpid.client.AMQConnectionFactory.createConnection(AMQConnectionFactory.java:125)
        at
org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:342)
        at
org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:288)
        at
org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225)
        at
org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
        at
org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:456)
        ... 5 more
Caused by: java.lang.IllegalArgumentException: BrokerDetails details
required for connection.
        at
org.apache.qpid.jms.failover.FailoverSingleServer.<init>(FailoverSingleServer.java:54)
        at org.apache.qpid.jms.FailoverPolicy.<init>(FailoverPolicy.java:68)
        at
org.apache.qpid.client.AMQConnection.<init>(AMQConnection.java:303)
        at
org.apache.qpid.client.AMQConnectionFactory.createConnection(AMQConnectionFactory.java:121)


Here's the spring config:

 
    <bean id="connectionFactory"
class="org.apache.qpid.client.AMQConnectionFactory">
        <constructor-arg index="0"
                        
value="amqp://guest:guest@clientid/shift?brokerlist='tcp://localhost:5672'"
/>
    </bean>


    <bean id="cachedConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory"
          p:targetConnectionFactory-ref="connectionFactory"
          p:sessionCacheSize="1" />

    
    <bean id="destination" class="org.apache.qpid.client.AMQAnyDestination">
        <constructor-arg value="amq.direct" />
    </bean>

    
    <bean id="jmsTemplate"
          class="org.springframework.jms.core.JmsTemplate"
          p:connectionFactory-ref="cachedConnectionFactory"
          p:defaultDestination-ref="destination" />



Here's how I create each thread (shortened it up a bit):


for (/the list of classes/) {
                String className = /the classname in the list/;
                String fullyQualifiedClassName = packageName + "." +
className;
                CPEDeviceCollector collector = null;
                try {
                    collector = (CPEDeviceCollector)
Class.forName(fullyQualifiedClassName).newInstance();
                    // Start a new thread for each device.
                    collector.setJmsTemplate(jmsTemplate);

                    new Thread(collector).start();
                } catch (Exception e) {
                    throw new Exception("Class not found:" +
e.getMessage());
                }
            }


When I actually send a message using the jmstemplate in each thread:

final byte[] data = result.toString().getBytes();

        jmsTemplate.send(new MessageCreator() {

            public Message createMessage(final Session session) throws
JMSException {
                BytesMessage message = session.createBytesMessage();
                message.writeBytes(data);
                return message;
            }
        });


The spring jmsTemplate is supposed to be threadsafe, so it must be something
I've configured wrong in the spring context I suspect.





--
View this message in context: http://qpid.2158936.n2.nabble.com/java-broker-with-jms-and-point-to-point-tp7582591p7582638.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Mime
View raw message