Announcement Announcement Module
No announcement yet.
sending requests Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • sending requests


    How can I send requests via Spring Integration to a Spring WebService for every lets say every 5 mins automatically??In other words how can a client invoke a Spring WebService every 5 mins for example??Should I do it with threads???In moment I have done it this way using threads but any suggestions how to configure this sort of problem in Spring Integration in a more professional way?? Would appreciate help Thanks

    System.out.println("Request message payload :"+message.getPayload());
    			System.out.println("Thread Sleeping now"); 
    Last edited by ashleyvijay; Nov 4th, 2008, 03:53 AM.

  • #2
    Nobody has a solution??

    Nobody has ideas?? suggestions?? Would really appreciate help.


    • #3
      I suggest you look over the manual to see how MessageSource's work but you could implement as below so you are creating a message source which will then be polled by Spring Integration.

      <si:inbound-channel-adapter ref="exampleSource" channel="webServiceRequests">     
              <si:interval-trigger interval="300" time-unit="SECONDS"/>
      public class ExampleSource implements MessageSource<String>{
      	public Message<String> receive() {
      		return new GenericMessage<String>("<request/>");
      Alternatively you could implement TaskSchedulerAware which will then give you access to the TaskScheduler used by SI internally which allows you to schedule the execution of task. I would go for MessageSource since it will be easier to evolve if your requirements get more complex.
      Last edited by JonasPartner; Nov 4th, 2008, 05:16 AM. Reason: corrected for RC 1 namespace


      • #4
        Thanks for the reply. But I have a publish-subscribe channel and in tht case how can I use "poller"??

        	<publish-subscribe-channel id="sendChannel"/>
        <!-- The service activator receives from the 'sendChannel',invokes the handler, and sends the reply Message to the 'replyChannel'. -->
        <service-activator input-channel="sendChannel" ref="msgConverter1" output-channel="mailChannel"/>
        <service-activator input-channel="sendChannel" ref="msgConverter1" output-channel="jmsChannel"/>
         <service-activator input-channel="sendChannel" ref="msgConverter1" output-channel="consoleChannel"/>
        <!-- The handler invokes the WebService for the given URI and returns a reply Message. -->
        <ws-handler id="msgConverter1" uri="http://localhost:8080/Trial1/companyservice"/>
        <!-- The response from the service is sent to different target adapters. -->
        <channel-adapter id="consoleChannel" target="console"/>
        <console-target id="console"/>
        <channel-adapter id="mailChannel" target="mailTarget"/>
        <mail-target id="mailTarget" header-generator="mailHeader" username="root" password="root" host="localhost" />
        	<beans:bean id="mailHeader" class="org.springframework.integration.adapter.mail.StaticMailHeaderGenerator">
        	<beans:property name="to" value="[email protected]" />
        	<beans:property name="subject" value="Test Mail" />
        	<beans:property name="from" value="[email protected]"/>
        	<beans:property name="replyTo" value="[email protected]"/>
        <channel-adapter id="jmsChannel" target="jmsTarget"/>
        <jms-target id="jmsTarget" connection-factory="connectionFactory" destination="destination"/>
        <beans:bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
          <beans:property name="brokerURL" value="tcp://localhost:61616" />
        <beans:bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
           <beans:constructor-arg index="0" value="HelloJMS"/>


        • #5
          I have a feeling from your response that you did not look at the reference documentation. The point of the inbound channel adapter is to poll a source and send to a channel. The outbound channel adapter polls a channel and sends to a consumer.

          Therefore in the case of the inbound channel adapter the poller is polling the provided implementation of MessageSource and sending to the provided MessageChannel which can be a PollableChannel or a SubscribableChannel. See SourcePollingChannelAdapter.


          • #6
            Ok I understand now after the latest realease version.Thank u