L.S., If the goal is just to send a message from a client, you can also just use the plain JMS API starting from the ActiveMQConnectionFactory. There's no real benefit in using JNDI here, I guess...
Regards, Gert Vanthienen ------------------------ Open Source SOA: http://fusesource.com Blog: http://gertvanthienen.blogspot.com/ 2009/7/31 lekkie <[email protected]>: > > I was trying to access a JMS consumer service exposed on Servicemix and its > throwing the follwoing exception: > > javax.naming.NameNotFoundException: queue/A/Soap > at > org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215) > at javax.naming.InitialContext.lookup(InitialContext.java:351) > at > testDriver.WebServiceTestDriver.sendBinaryFileJMS(WebServiceTestDriver.java:89) > at testDriver.WebServiceTestDriver.main(WebServiceTestDriver.java:71) > > > Here is my client code (running from eclipse): > > String fileName = "C:\\binaryfile.html"; > byte[] payload = getBytesFromFile(fileName); > String dest = "queue/A/Soap"; > Properties env = new Properties(); > if (System.getProperty("java.naming.provider.url") == null) { > env.put("java.naming.provider.url", "tcp://localhost:61616"); > } > if (System.getProperty("java.naming.factory.initial") == null) { > env.put("java.naming.factory.initial", > "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); > } > InitialContext ic = new InitialContext(env); > ConnectionFactory confac = (ConnectionFactory) > ic.lookup("ConnectionFactory"); > Connection connection = confac.createConnection(); > Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); > MessageProducer producer = session.createProducer((Destination) > ic.lookup(dest)); > BytesMessage bm = session.createBytesMessage(); > bm.writeBytes(payload); > producer.send(bm); > connection.close(); > > > and here is my xbean.xml on servicemix which imho look good: > > <beans xmlns:jms="http://servicemix.apache.org/jms/1.0" > xmlns:is="http://services.is" > xmlns:amqpool="http://jencks.org/amqpool/2.0"> > > <bean id="connectionFactory" > class="org.apache.activemq.pool.PooledConnectionFactory"> > > <property name="connectionFactory"> > <bean > class="org.apache.activemq.ActiveMQConnectionFactory"> > <property name="brokerURL" > value="tcp://localhost:61616" /> > </bean> > </property> > > <!--Configure maximum connections used by the pool --> > <property name="maxConnections" value="10" /> > > <!--Configure maximum sessions per connection --> > <property name="maximumActive" value="10" /> > </bean> > > <jms:endpoint service="is:isJMSFileConsumer" > endpoint="isJMSFileConsumer" > targetService="is:isFTPWriter" > targetEndpoint="isFTPWriter" > role="consumer" > destinationStyle="queue" > jmsProviderDestinationName="queue/A/Soap" > connectionFactory="#connectionFactory" > soap="true" > > defaultMep="http://www.w3.org/2004/08/wsdl/robust-in-only"/> > </beans> > > -- > View this message in context: > http://www.nabble.com/NameNotFoundException-for-Queue-%28ServiceMIX-JMS%29-tp24759155p24759155.html > Sent from the ServiceMix - User mailing list archive at Nabble.com. > >
