Announcement Announcement Module
Collapse
No announcement yet.
Rabbit poller set up problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rabbit poller set up problem

    Hi,

    I'm new and a noob still. The problem I'm facing is a batch engine (without Spring Batch for the beginning) that has to:
    1. Poll a queue for job messages
    2. When a message is in the queue, read it and produce a useful object out of the concatenated string
    3. Pass the message to another service that downloads a file described in it
    4. Do several operations in that file (presumably in separate services)
    5. Produce a new file, upload it and restart the process

    The problem is, the messages seam to be vanishing.

    the context xml file:
    Code:
    <context:component-scan base-package="com.example" />
    <context:property-placeholder location="classpath:batch.properties" />
    <import resource="classpath:datasource-context.xml" />
    
    <context:annotation-config />
    
    <bean id="test.service" class="com.example.converter.service.StringConcatService" />
    <int-amqp:inbound-channel-adapter
    		queue-names="doc" channel="input" connection-factory="rabbitConnFactory"  />
    <si:channel id="input">
    	<int:queue capacity="1" />
    </si:channel>
    
    <si:channel id="output" />
    <int-stream:stdout-channel-adapter
    	channel="output" auto-startup="true" />
    <int:poller fixed-delay="1000" default="true" />
    
    <!-- Service activators -->
    
    <si:service-activator input-channel="input" ref="test.service"
    	method="concat" output-channel="output" />
    The main class:

    Code:
    @Component
    public class Main {
    	public static void main(String[] args) {
    
    		final AbstractApplicationContext context = new ClassPathXmlApplicationContext(
    				"classpath:app-context.xml");
    
    		context.registerShutdownHook();
    
    		PollableChannel input = (PollableChannel) context.getBean("input");
    		input.receive();		
    		
    	}
    }
    Now this service is just a string concatenation service but it should work. Tried this also with a chain, also messages vanish but the queue (in rabbit web admin) are going down on items.

    Am I missing something?

    Appreciate any advice, Thanks
    pejot

  • #2
    The fact you are using a <queue/> channel means the message will immediately removed from the Rabbit queue. If you remove the <queue/> element, you don't need a poller and your service will be called on the adapter's thread.

    Also, turn on DEBUG logging for org.springframework.integration and you can trace the message flow.

    Comment


    • #3
      Awesome,

      thanks for your answer. Figured out the problem was in the "si" namespace of the service activator, spring just ignored it and bypassed the service activator entirely.
      Also have two questions:
      - how do I turn on the DEBUG logging with SI (I'm sure it's a noob question but looked and couldn't find it)
      - How do I start the context running when I's not a PollableChannel any more ?

      Comment


      • #4
        Just add log4j.xml to the classpath; something like...

        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
        <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
        
        	<!-- Appenders -->
        	<appender name="console" class="org.apache.log4j.ConsoleAppender">
        		<param name="Target" value="System.out" />
        		<layout class="org.apache.log4j.PatternLayout">
        			<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
        		</layout>
        	</appender>
        
        	<!-- Loggers -->
        	<logger name="org.springframework">
        		<level value="info" />
        	</logger>
        
        	<logger name="org.springframework.integration">
        		<level value="debug" />
        	</logger>
        
        	<!-- Root Logger -->
        	<root>
        		<priority value="warn" />
        		<appender-ref ref="console" />
        	</root>
        
        </log4j:configuration>
        The adapter will start running immediately, when the context is created.
        Last edited by Gary Russell; Feb 13th, 2013, 11:36 AM.

        Comment


        • #5
          The adapter does start automatically, many thanks for that advice! However have problems with the log4j settings. I've set everything on debug and added the log4j.xml to classpath by setting "included **/*.java **/*.xml" on the resources folder in Eclipse, still don't get any additional information though.

          Comment


          • #6
            Do you have the log4j jar on your classpath? How are you managing dependencies, maven?

            Comment


            • #7
              That's the dependency in maven, hope it's the right one?

              Code:
              <dependency>
                	<groupId>ant</groupId>
                	<artifactId>ant-apache-log4j</artifactId>
               	<version>1.6.5</version>
               </dependency>

              Comment


              • #8
                I am not sure why you are using an ant version, but it should be ok; I use

                Code:
                		<dependency>
                			<groupId>log4j</groupId>
                			<artifactId>log4j</artifactId>
                			<version>1.2.17</version>
                		</dependency>
                It might be picking up another log4j config file higher on the classpath - you can debug that by adding

                Code:
                -Dlog4j.debug=true
                to your launcher VM arguments.

                Comment


                • #9
                  Ok,

                  will check that out. Many thanks Gary!

                  Cheers,
                  pejot

                  Comment

                  Working...
                  X