Results 1 to 7 of 7

Thread: Sending messages multiple times

  1. #1
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Default No Response

    Hi Jonas,

    Sorry abt the previous post.I didnt notice it.Anyways I tried ur suggestion from http://forum.springframework.org/sho....php?t=62936.I have no exceptions but I cant c any response message being sent(neither as email nor as jms).Infact I dnt know whether the request message accesses the WebService.Please help.

    SI.java
    Code:
    public class SI {
    	public static void main(String[] args)throws MessagingException {
    		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("si.xml",SI.class);
    
    // Compose the XML message according to the server's schema
    		String requestXml =
    			"<hr:CompanyRequest xmlns:hr=\"http://mycompany.com/hr/schemas\">" +
    			"<hr:Company>"+
    	        "<hr:CompanyName>IT</hr:CompanyName>"+
                "</hr:Company>"+
                "</hr:CompanyRequest>";
    
    // Create the Message object
    // In this case the service expects a SoapAction header
    		Message<String> message = MessageBuilder.withPayload(requestXml)
    				.setHeader(AbstractWebServiceOutboundGateway.SOAP_ACTION_PROPERTY_KEY, "http://mycompany.com/hr/schemas")
    				.build();
    // Send the Message to the handler's input channel
    		
    ((MessageChannel) context.getBean("sendChannel")).send(message);
    		
    	   }
    }
    si.xml
    Code:
    <message-bus/>
        <channel id="sendChannel">
        <queue capacity="25"/>
    </channel>
    <inbound-channel-adapter ref="source"  id="requestChannel" method="main" channel="sendChannel">
        <poller>
            <interval-trigger interval="5" time-unit="SECONDS" fixed-rate="true"/>
        </poller>
    </inbound-channel-adapter>
        
    <beans:bean id="source" class="rc1.SI"/>
    
    <!--Sending WebService request -->			         
    
    <ws:outbound-gateway id="gateway" request-channel="requestChannnel" 
    				         reply-channel="responseChannel"
    				        uri="http://localhost:8080/SpringWebService/"/>
    				         
    <publish-subscribe-channel id="responseChannel"/>
    
    <!--Response from WebService sent as email-->			         
    				         
    <mail:outbound-channel-adapter id="MailOut" host="localhost"  username="root" password="root"/>
    <mail:header-enricher  input-channel="responseChannel"  subject="HelloMailTest" output-channel="MailOut"
                         to="black@localhost"
                        from="white@localhost" cc="blue@localhost"
                       overwrite="false"/>
                       
    <!--Response from WebService sent as jms message-->			         
                                  
    <jms:outbound-gateway request-channel="responseChannel" connection-factory="connectionFactory"  jms-queue="HelloQueue" message-converter="HeaderMappingMessageConverter" reply-channel="jmsReplyTo"/>
    	<beans:bean id="HeaderMappingMessageConverter" class=" org.springframework.integration.jms.HeaderMappingMessageConverter">
    <beans:property name="extractPayload" value="true"/>
    </beans:bean>
    
    <beans:bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <beans:property name="brokerURL" value="tcp://localhost:61616"/>		
    </beans:bean>
    
    <beans:bean id="HelloQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <beans:constructor-arg value="finally" />
    </beans:bean>
    
    <stream:stdout-channel-adapter  append-newline="true" id="jmsReplyTo"/>
    </beans:beans>
    Last edited by ashleyvijay; Nov 10th, 2008 at 08:02 AM. Reason: Post already exists

  2. #2
    Join Date
    Oct 2007
    Location
    London, England
    Posts
    108

    Default

    I am not sure I understand how this question differs from your previous question here, sending requests. Unless you can expand a bit my answer would be the same.
    Jonas Partner
    OpenCredo

  3. #3
    Join Date
    Oct 2007
    Location
    London, England
    Posts
    108

    Default

    It would be good to avoid editing posts to the extent that they are in fact a new post. It is confusing to people who find responses which no longer relate to the initial post.

    I would suggest you need to write more tests. If the whole is not working as you expect then test the parts.

    It looks you are trying to poll a static main method which is creating an application context. This does not relate to the suggestion I made in the previous thread.
    Last edited by JonasPartner; Nov 10th, 2008 at 08:32 AM. Reason: typo
    Jonas Partner
    OpenCredo

  4. #4
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Default interval trigger triggers only once!

    Hi finally I can c the response message being sent out with the below config but only one response instead of many of them: I think it just by passes the interval trigger and gives out the response but Im also not sure whether my interval trigger config is correct?Please help

    Code:
    <message-bus/>
     <channel id="requestChannel"/>
     <inbound-channel-adapter ref="source" method="main" channel="requestChannel">
       <poller>
            <interval-trigger interval="120"  time-unit="SECONDS" initial-delay="5"/>
        </poller>
        </inbound-channel-adapter>
    <beans:bean id="source" class="rc1.SI"/>
    <!--Sending WebService request -->			         
    
    <ws:outbound-gateway id="gateway"
    				         request-channel="requestChannel" 
    				         reply-channel="responseChannel"
    				         uri="http://localhost:8080/SpringWebService/"/>
    				         
    <publish-subscribe-channel id="responseChannel"/>

  5. #5
    Join Date
    Oct 2007
    Location
    Toronto, ON
    Posts
    90

    Default

    Well, you'll have one request sent to the web service, and one request coming back, therefore it's exactly one message arriving on the pubsub channel.

    However, I notice that you're using a gateway for Jms, therefore unless someone is picking up that message, and replying to it, you'll see nothing on the <stream:stdout-channel-adapter/>
    Marius Bogoevici,
    Spring Integration Committer

  6. #6
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Default

    Well, you'll have one request sent to the web service, and one request coming back, therefore it's exactly one message arriving on the pubsub channel.
    Actually I wanted to send multiple requests to the webservice each after every120 secs so tht I would get multiple respective responses.Tht is y I used interval trigger which should eventually trigger the request to the webservice every 120 secs.But currently I can c only one response as jms message in the jms queue instead of many of them.I dnt know y inspite of my config being right

    Quote Originally Posted by mbogoevici View Post
    However, I notice that you're using a gateway for Jms, therefore unless someone is picking up that message, and replying to it, you'll see nothing on the <stream:stdout-channel-adapter/>
    This I would totally agree with u but doesnt matter.

    I also tried this way but no progress:still it sending only one request.

    Code:
    <channel id="requestChannel">
    <queue capacity="25"/>
    </channel>
    <ws:outbound-gateway id="gateway"
    				         request-channel="requestChannel" 
    				         reply-channel="responseChannel"
    				         uri="http://localhost:8080/SpringWebService/">
    <poller>
    <interval-trigger interval="60"  time-unit="MILLISECONDS" fixed-rate="true"/>
    </poller>
    </ws:outbound-gateway>
    Last edited by ashleyvijay; Nov 11th, 2008 at 04:06 AM.

  7. #7
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Default

    Ok I got it fixed! I did just the way Jonas told me.I moved the stuff to be polled in another method instead of having it in the main method and it works perfectly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •