Announcement Announcement Module
Collapse
No announcement yet.
jms-source cannot be configured with a jms-template Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Try adding a breakpoint in: AbstractMessageListenerContainer.commitIfNecessary (..)

    That is in the spring-jms.jar.

    -Mark

    Comment


    • #17
      Debug results

      I ran debug test and see that the commit is not actually being done , its being skipped at
      Code:
      // Commit necessary - but avoid commit call within a JTA transaction.
      if (isSessionLocallyTransacted(session)) { skips } 
      returns back..
      within
      Code:
      protected void commitIfNecessary(Session session, Message message) throws JMSException {
      	// Commit session or acknowledge message.
      	if (session.getTransacted()) {
      	  // Commit necessary - but avoid commit call within a JTA transaction.
      	  if (isSessionLocallyTransacted(session)) {
      			// Transacted session created by this container -> commit.
      			JmsUtils.commitIfNecessary(session);
      	  }
      	}
      	else if (isClientAcknowledge(session)) {
      		message.acknowledge();
      	}
      }
      The actual code that denies commit seems to be
      Code:
      protected boolean isSessionLocallyTransacted(Session session) {
      		return super.isSessionLocallyTransacted(session) &&
      				!ConnectionFactoryUtils.isSessionTransactional(session, getConnectionFactory());
      	}
      Last edited by diippi; Feb 21st, 2008, 11:33 AM. Reason: Addendum

      Comment


      • #18
        Jta

        How is my jms transaction part of JTA <as the commit didnt happen because of that > and what can be done to change that ?

        Comment


        • #19
          updates

          Any updates on this ? How do I make sure the session is commited ?

          Comment


          • #20
            Since your listener is receiving within a JTA transaction, the commit is not going to happen within the local scope of the JMS Session at all. Are you intentionally using a JTA-managed transaction here?

            -Mark

            Comment


            • #21
              JTA by default maybe

              No , Im not using JTA ..its being used by default <thru spring> somehow..
              Here is my config in whole :
              Code:
              <message-bus auto-create-channels="true" error-channel="errorChannelRequest"/>
              
              <channel id="FMSRequestChannel"/>
              	 
                 	<!-- JMS Source (request queue) --> 
              <jms-source id="wmqConsumer1" 
              	connection-factory="connectionFactoryWMQ_IFT_FMS" 
              	destination-name="1GFP.IFT.PAYMENT.501.REQUEST" 
              	channel="FMSRequestChannel"/>
              	
              <endpoint input-channel="FMSRequestChannel"
              		  handler-ref="fmsListener"
              	          handler-method="onMessage"/>
              
              	<!-- WebSphere connection factory -->
                  <beans:bean id="connectionFactoryWMQ_IFT_FMS" class="com.ibm.mq.jms.MQQueueConnectionFactory">
                      <beans:property name="queueManager" value="QMLD001A" />
                      <beans:property name="transportType" value="1" />
                      <beans:property name="hostName" value="eis-qmld001-01.usa.net" />
                      <beans:property name="channel" value="1GFP.CLIENT2" /><!-- 1SWF.CLIENT2 -->
                      <beans:property name="port" value="60001" />
                  </beans:bean>			
                  
                  <!-- Reply message Listener 	DO NOT MODIFY THIS -->
                  <beans:bean id="fmsListener" class="com.cib.gfits.frameworks.handler.reply.ReplyHandler" >	
                  </beans:bean >
                  
              	<!-- Error handling DO NOT MODIFY THIS -->
              	<channel id="errorChannelRequest" publish-subscribe="true" capacity="500"/> 
              	<endpoint input-channel="errorChannelRequest"
              	          default-output-channel="outputChannel"
              	          handler-ref="errorHandlerRequest"
              	          handler-method="logError"/>
              	          
              <beans:bean id="errorHandlerRequest" class="com.cib.gfits.frameworks.handler.error.ErrorHandler"/>
              There is no where that I specify the Tx Manager. One thing I would like to point out is that I am testing this thru standalone junit class, if it makes any difference.

              Comment


              • #22
                I have added a configurable "acknowledge" attribute in the XML for <jms-source/> which accepts the same enumerated values as a Spring JMS listener container: auto, client, dups-ok, transacted. For now, the default is consistent with listener-container (auto) rather than "transacted" as it was previously. This may change, but in any case, you can now configure "auto" (not typically recommended) or "client", etc.

                Note that all adapters have now been moved to a separate "spring-integration-adapters" project, so if you checkout via SVN, look for "spring-integration-adapters" (and add the corresponding JAR file to your dependencies).

                Enabling adapter support in the namespace requires a minor change in the "schemaLocation" (notice spring-integration-adapters-1.0.xsd):
                Code:
                <?xml version="1.0" encoding="UTF-8"?>
                <beans xmlns="http://www.springframework.org/schema/beans"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:integration="http://www.springframework.org/schema/integration"
                    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/integration
                        http://www.springframework.org/schema/integration/spring-integration-adapters-1.0.xsd">

                Comment


                • #23
                  Mark,
                  I tried to use the message-converter property of jms-source but my converter is never invoked.

                  Xml snippet
                  Code:
                   <jms-source id="jms-src"  
                  		connection-factory="connectionFactoryWMQ" 
                  		destination-name="${wmq.reply.destination.name}" 
                  		channel="RequestChannel" acknowledge="auto" message-converter="mc" />
                  <beans:bean id="mc" class="com.test.RequestMessageConverter">		</beans:bean>

                  Any idea what is going wrong here?

                  basically, I am trying to acknowledge the message using the converter but converter itself is not getting called.

                  Any help will be appreciated
                  Thanks in advance.
                  Vikas

                  Comment


                  • #24
                    If you want to explicitly acknowledge, you should be setting the "acknowledge" attribute's value to "client" rather than "auto".

                    Have you attempted to verify (with a breakpoint, printout, etc.) that the MessageConverter is actually being invoked (it should be)?

                    -Mark

                    Comment


                    • #25
                      Apologies..for that mistake, i made it auto to remove message from queue.
                      Yes i tried to debug it but it never got call.
                      Another observation was it does auto acknowledge even with client value.
                      It never acknowledges when i set it to transacted.

                      Comment


                      • #26
                        Can you turn on DEBUG level logging? You should see messages from the underlying listener container with information about the Session (whether it's transactional or not, etc.)

                        -Mark

                        Comment


                        • #27
                          I tried to debug the spring code and found that I need to fromMessage is called thus i need override the following method.
                          Code:
                          	public Object fromMessage(Message message) throws JMSException,MessageConversionException
                          However i am still not able to acknowledge the message and why is not "client" mode not working as expected.

                          Thanks/Vikas

                          Comment


                          • #28
                            I tried to set the debugging level but didn't found any information about session can you please point me to spring integration classs which can reveal this the information about session, i can add a breakpoint and check the values.

                            After overriding "fromMessage" my converter is getting invoked but acknowledge is not working. Do i need to do anything more here..
                            Regards/Vikas

                            Comment


                            • #29
                              The logging that you are interested in occurs within "org.springframework.jms.listener.AbstractPollingM essageListenerContainer", so be sure to configure that package for DEBUG level. Spring Integration's JMS source adapter is simply delegating to the underlying support in Spring core.

                              As far as the acknowledgment is concerned, keep in mind that if you are running within a transactional session, client or auto have no effect.

                              Can you explain a bit more about what you are trying to do with the acknowledgment? It shouldn't be necessary to add a converter just for acknowledging the message. If you use the "client" setting, the Spring listener container will acknowledge as long as the message is received and the listener is invoked successfully.

                              -Mark

                              Comment


                              • #30
                                Thanks for all valuable information.

                                I want to acknowledge the message only if i am able to process it. I am writing custom message handler by extending DefaultIncomingMessageHandler. I would to like acknowledge only after doing some processing on the message, this to ensure that unprocessed messages will not be lost. I hope i was able to explain my use case.

                                I was not able to figure out the about trasacted state. I could see following logs which look relevant but dont give any information.

                                2008-04-09 16:51:30,905 DEBUG [org.springframework.beans.CachedIntrospectionResul ts] Found bean property 'sessionAcknowledgeMode' of type [int]
                                2008-04-09 16:51:30,905 DEBUG [org.springframework.beans.CachedIntrospectionResul ts] Found bean property 'sessionAcknowledgeModeName' of type [java.lang.String]
                                2008-04-09 16:51:30,905 DEBUG [org.springframework.beans.CachedIntrospectionResul ts] Found bean property 'sessionTransacted' of type [boolean]

                                Comment

                                Working...
                                X