1
votes

In our system, external clients put messages on JMS queues. The requirement is for our Spring Integration application to pick up messages from those queues and process them. My initial stab at this is using the following configuration:

<int:channel id="source_channel" />

<int-jms:inbound-channel-adapter 
   id="source"
   channel="source_channel"
   destination-name="jms-queue-name"
   connection-factory="...">
   <int:poller fixed-rate="1000" />
</int-jms:inbound-channel-adapter>

<int:service-activator input-channel="source_channel" ref="sourceMessageReciever"/>

I am expecting the service activator bean to process the message when a client puts it on the 'jms-queue-name' queue, but this is not happening. Is this the correct approach, or do I need to use a messageGateway to do this? Thanks,

Rose

4
Turn on DEBUG logging; all should become evident; if you have questions about what you see in the log, amend your question.Gary Russell

4 Answers

0
votes

The difference between InboundChannelAdapter and MessageGateway is just that Adapter is working uni-directional rather then bidirectional.

I don't have really an insight what might be wrong but did you test if that your configuration of the ConnectionFactory for JMS is working as expected?

0
votes

What is the signature of the method in your service activator class ? Check they have one (and only one) public method, or add the method attribute to your service activator definition.

Usually, you should prefer the message-driven-channel-adapter instead of the jms:inbout-channel-adapter. This last adapter use the poller to check new message, while the message-driven-channel-adapter use the Spring message listener.

0
votes

I have achieved similar requirements with the help of following configurations:

<context:component-scan base-package="somePackage"/>

<int:channel id="jmsInChannel" />

<bean id="jmsInboundContainer"
      class="org.springframework.jms.listener.DefaultMessageListenerContainer"
      destroy-method="destroy">
    <property name="connectionFactory" ref="..." />
    <property name="destination" ref="jmsQueue" />
    <property name="sessionTransacted" value="true" />
</bean>

<int-jms:message-driven-channel-adapter channel="jmsInChannel"
    container="jmsInboundContainer" acknowledge="transacted" />

<int:service-activator input-channel="jmsInChannel" ref="myService" />

My Service implementation is as follows:

@Component
public class MyService {

    @ServiceActivator
    public void processMessage(
        @Headers Map<String, Object> headers,
        @Payload Message<String> paylaod) {

        ...
        ...
    }
}
0
votes

I got the same issue then I tried to declare inbound queue explicitly and used it in inbound-channel-adapter.

It worked!

<int:channel id="source_channel" />

<int-jms:inbound-channel-adapter 
   id="source"
   channel="source_channel"
   destination="inboundQueue"
   connection-factory="...">
   <int:poller fixed-rate="1000" />
</int-jms:inbound-channel-adapter>

<int:service-activator input-channel="source_channel" ref="sourceMessageReciever"/>

<bean id="inboundQueue" class="org.apache.activemq.command.ActiveMQQueue">
   <constructor-arg value="jms-queue-name"></constructor-arg>
</bean>