I have the following flow:
1) message-driven-channel-adapter ->
1.1) output-channel connected to -> service-activator -> outbound-channel-adapter (for sending response)
1.2) error-channel connected to -> exception-type-router
1.2.1) message is sent to different queues depending on the exception type using outbound-channel-adapter
MessageDrivenChannelAdapter uses DefaultMessageListenrContainer and OutboundAdapter uses JMSTemplate
Have used same cachingconnectionfactory for inbound and outbound adapters,
set acknowledge="transacted" in messageDrivenChannelAdapter
set cacheLevel as CACHE_CONSUMER in DefaultMessageListenerContainer
set cacheProducers=true and cacheConsumers=false in CachingConnectionFactory
I am so confused as how jms session/producer/consumer is created and handled in this flow.
1) whether the consumers and producers used by inbound adapter, outbound adapters(used for response and the error queues) are created from the same session i.e. whether producers and consumers used in a thread are created from the same session?
2) And Just wanted to confirm as whether there are any disadvantage/issues in using cachingconnectionfactory even after setting 1)cacheConsmers to false in the factory and 2)cache level to CACHE_CONSUMER at the DefaultMessageListenerContainer. Because , it is confusing to read the forums saying that cachingconnectionfactory should not be used.
3)Also , have a doubt on the execution flow: In the flow, when will the service activator method execution complete ? Will it complete only after the message is sent to the output queue?
Please advise
When the container
acknowledgemode
istransacted
, the container session is bound to the thread and will be used by any upstreamJmsTemplate
that is configured to use the same connection factory, as long as there is no asynch handoff (QueueChannel
orExecutorChannel
); the defaultDirectChannel
runs the downstream endpoints on the container thread.The service activator method is invoked (and "completes") before sending the message to the outbound adapter.