I have been trying to use the JmsMessageDrivenSourceAdapter. By my understanding of the documentation, it should create a container listener over a queue and allow for multiple receivers to be passed the messages as they arrive. I have gotten this to work using Spring's standard SimpleMessageListenerContainer and MessageListenerAdapter and see the connection created to the queue manager. Although there are no critical errors when it is run, there are no connections to the queue manager. I have tried it with both WMQ Series and Active MQ with the same results. Here is the code.
Configuration
<message-bus dispatcher-pool-size="25" auto-create-channels="true" >
<annotation-driven />
<context:component-scan base-package="com.springinttest" />
<channel id="inputChannel1" />
<endpoint input-channel="inputChannel1" handler-ref="MyMdp"
handler-method="processMessage">
<concurrency core="5" max="25" />
</endpoint>
<beans:bean id="MySourceAdapter"
class="org.springframework.integration.adapter.jms .JmsMessageDrivenSourceAdapter"
lazy-init="false" init-method="initialize">
<beans:property name="connectionFactory"
ref="connectionFactory" />
<beans:property name="destination" ref="destination" />
<beans:property name="channel" ref="inputChannel1" />
</beans:bean>
<beans:bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFacto ry">
<beans:property name="brokerURL" value="tcp://localhost:61616" />
</beans:bean>
<beans:bean id="destination"
class="org.apache.activemq.command.ActiveMQQueue">
<beans:constructor-arg index="0" value="myQueue"/>
</beans:bean>
<beans:bean id="MyMdp" class="com.springinttest.MyMdp" />
</beans:beans>
Handler
package com.springinttest;
import org.springframework.integration.annotation.Message Endpoint;
import org.springframework.integration.annotation.Handler ;
import org.apache.log4j.Logger;
@MessageEndpoint(input="inputChannel1")
public class MyMdp {
private static final Logger LOGGER = Logger.getLogger(MyMdp.class);
public MyMdp() {
LOGGER.warn("Constructor Set");
}
@Handler
public void processMessage(String message) {
try {
System.out.println(message.toString());
LOGGER.warn("Received message is: " + message.toString());
} catch (Exception e) {
System.out.println("Captain Chaos");
// handle this-somehow
}
}
}


Reply With Quote