Announcement Announcement Module
Collapse
No announcement yet.
ItemReader integration with message channel Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ItemReader integration with message channel

    Hi,
    I am creating a step with reader reading items from spring integration message channel.

    The "itemMsgQueue" is the message queue contains data. "item" is the channel which ItemReader will read from.
    It works fine if I am using the "org.springframework.batch.integration.chunk.Messa geSourcePollerInterceptor" to poll directly from JMS MessageSource and send to the channel:

    Code:
    <integration:channel id="items">
    		   <integration:queue/> 
    		   <integration:interceptors>
    				<bean id="interceptor" class="org.springframework.batch.integration.chunk.MessageSourcePollerInterceptor">
    					<property name="messageSource">
    						<bean class="org.springframework.integration.jms.JmsDestinationPollingSource">
    							<constructor-arg>
    								<bean class="org.springframework.jms.core.JmsTemplate">
    									<property name="connectionFactory" ref="connectionFactory" />
    									<property name="defaultDestinationName" value="itemsMsgQueue" />
    									<property name="receiveTimeout" value="100" />
    								</bean>
    							</constructor-arg>
    						</bean>
    					</property>
    				</bean>
    			</integration:interceptors>
    </integration:channel>
    
    <integration:gateway service-interface="org.springframework.batch.item.ItemReader" id="itemReader" default-reply-channel="items" default-reply-timeout="5000"/>
    
    <batch:job id="TestJob">
    		<batch:step id="TestStep1">
    		    <batch:tasklet>
    		       <batch:chunk commit-interval="3" reader="itemReader" processor="logProcessor" writer="nullWriter">
    		       </batch:chunk>
    		    </batch:tasklet>
    		</batch:step>
    		
    </batch:job>

    However, if I want to use the message-driven-channel-adapter to send the message to the channel instead, it doesn't seem to work. The job finished with 0 item readed:

    Code:
    <integration:channel id="items">
    			<integration:queue capacity="1000" /> 
    </integration:channel>
    
    <int-jms:message-driven-channel-adapter connection-factory="connectionFactory" destination-name="itemMsgQueue" channel="items" />
    
    <integration:gateway service-interface="org.springframework.batch.item.ItemReader" id="itemReader" default-reply-channel="items" default-reply-timeout="5000"/>
    
    <batch:job id="TestJob">
    		<batch:step id="TestStep1">
    		    <batch:tasklet>
    		       <batch:chunk commit-interval="3" reader="itemReader" processor="logProcessor" writer="nullWriter">
    		       </batch:chunk>
    		    </batch:tasklet>
    		</batch:step>
    		
    </batch:job>

    Is there anything wrong with the second configuration ? I thought it must work.
    Thanks.
    K.
    Last edited by khuevu; Dec 16th, 2012, 11:38 PM.

  • #2
    Hi,

    I get the set up work with a JMS Polling adapter instead of the message driven adapter:

    Code:
    <int-jms:inbound-channel-adapter id="jmsIn" destination-name="itemsMsgQueue" channel="items">
    		    <integration:poller>
    	         <integration:interval-trigger interval="1" time-unit="SECONDS"/>
    		    </integration:poller>
    		</int-jms:inbound-channel-adapter>
    If I use the message-driven-adapter, messages from JMS message queue are not sent to the "item" message channel. As I understand, it should be sent everytime a new message come in the queue ?

    Can anyone help me to understand what is wrong ?

    Thanks.

    Comment

    Working...
    X