Hi,
I'm using a <int-jms:channel/> in order to cache some messages, it's ok I can see it with the JConsole (JMX).
Now I remove the message from the physical JMS queue using the JConsole (operation "purge()" on the queue MBean, but the removed messages is still processed by the adapter listening on the <int-jms:channel/>!
Does it normal ?
Maybe I don't use the <int-jms:channel/> in the correct way ?
Here is my Spring configuration :
And a JUnit test :Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-event="http://www.springframework.org/schema/integration/event" xmlns:int-jms="http://www.springframework.org/schema/integration/jms" xmlns:int-xml="http://www.springframework.org/schema/integration/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd http://www.springframework.org/schema/integration/event http://www.springframework.org/schema/integration/event/spring-integration-event-2.0.xsd http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml-2.0.xsd"> <bean id="myConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <property name="targetConnectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="vm://localhost?jms.redeliveryPolicy.maximumRedeliveries=-1"/> </bean> </property> <property name="sessionCacheSize" value="10"/> <property name="cacheProducers" value="false"/> </bean> <bean id="remoteConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <property name="targetConnectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=-1"/> </bean> </property> <property name="sessionCacheSize" value="10"/> <property name="cacheProducers" value="false"/> </bean> <int:publish-subscribe-channel id="eventChannel"/> <int-jms:channel id="jmsChannel" connection-factory="myConnectionFactory" queue-name="myQueue" cache="none"/> <int-event:inbound-channel-adapter id="eventAdapter" channel="eventChannel"/> <int:chain id="eventChain" input-channel="eventChannel" output-channel="jmsChannel"> <int:header-enricher> <int:header name="myHeader" value="myHeaderValue"/> </int:header-enricher> <int:transformer expression="payload+' myHeader='+headers.myHeader"/> </int:chain> <int-jms:outbound-channel-adapter id="syncOutboundAdapter" channel="jmsChannel" connection-factory="remoteConnectionFactory" destination-name="remoteQueue"/> </beans>
Code:import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.context.ApplicationContext; import org.springframework.integration.event.core.MessagingEvent; import org.springframework.integration.support.MessageBuilder; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:/META-INF/spring/test-jmschannel.xml"}) public class SimpleTest { @Resource private ApplicationContext context; @Test public void publishEvents() { context.publishEvent(new MessagingEvent(MessageBuilder.withPayload("EVENT1").build())); context.publishEvent(new MessagingEvent(MessageBuilder.withPayload("EVENT2").build())); context.publishEvent(new MessagingEvent(MessageBuilder.withPayload("EVENT3").build())); try { Thread.sleep(300000); //5mins } catch(Exception ex) { ex.printStackTrace(); } } }


Reply With Quote