I'm trying to prototype the integration part of an upcoming project. (I've read the message patterns, and know roughly what is going on at a high level with asynch messaging, but haven't done anything hands onwith it before). What I want to end up with is:
1) Client Webapp that sends messages to a queue and reads responses from a response queue.
2) Either another Webapp that host the queue, or set up the server to host the queue
3) Server Webapp that processes the client messages and provides a response.
What I have at the moment is:
applicationContext-integration.xml
(buggy) TestHandler.javaCode:<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd"> <annotation-driven /> <message-bus error-channel="errorChannel" /> <channel id="errorChannel" publish-subscribe="true" capacity="500" /> <channel id="testChannel"/> <endpoint input-channel="testChannel" handler-ref="testSender"> <!-- NOTE: A.B. 22/2/8 concurrency has some reasonable defaults but we probably want to explicitly define them because we will have some knowledge about the load and performance profiles we expect --> <concurrency core="2" max="4" queue-capacity="100" keep-alive="20" /> </endpoint> <jms-source connection-factory="connectionFactory" destination="testInputQueue" channel="testChannel"/> <beans:bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <beans:property name="brokerURL"><beans:value>tcp://localhost:61616</beans:value></beans:property> </beans:bean> <!-- <jms-target connection-factory="connectionFactory" destination="outputQueue" channel="outputChannel1"/> --> <beans:bean id="testSender" class="xxx.TestHandler"> </beans:bean> </beans:beans>
META-INF/context.xmlCode:public class TestHandler implements MessageHandler { public Message<?> handle(Message<?> message) { System.out.println("I handled a message"); return null; } public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext( "/main/webapp/WEB-INF/applicationContext-integration.xml", TestHandler.class); context.start(); ChannelRegistry channelRegistry = (ChannelRegistry) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME); MessageChannel inputChannel = channelRegistry.lookupChannel("testChannel"); MessageChannel outputChannel = channelRegistry.lookupChannel("testChannel"); inputChannel.send(new StringMessage("World")); System.out.println(outputChannel.receive().getPayload()); context.stop(); } }
When I start the TestHandler it attempts to load applicationContext-integration.xml but fails with "No bean named 'testInputQueue' is defined"Code:<Context> <Resource name="jms/ConnectionFactory" auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory" factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost" brokerName="LocalActiveMQBroker"/> <!-- Publish - subscribe example --> <!--Resource name="jms/someTopic" auth="Container" type="org.apache.activemq.command.ActiveMQTopic" description="my Topic" factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR"/--> <Resource name="testInputQueue" auth="Container" type="org.apache.activemq.command.ActiveMQQueue" description="my Queue" factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR"/> </Context>
What am I supposed to do to get the connectionFactory pointing to the deployed jms/connectionFactory rather than a locally created instance?
Tomcat 6.0
Spring Integration 1.0.0.m1
ActiveMQ 5.0.0


Reply With Quote
where the messages are handled, but have used a local ActiveMQ deployment rather than using Tomcat. Will try using Tomcat again after I get some more sleep.
