Announcement Announcement Module
Collapse
No announcement yet.
Need help with polling to a json based HTTP service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help with polling to a json based HTTP service

    Hi, I need a little help with the right way to poll to an external json based HTTP service using http gateway. I have requirement where I have to poll an external http json based service every minute and get the data into the messaging system. I would have assumed that an http inbound adapter/gateway would have been the right fit, but it behaves differently, it essentially exposes an http endpoint and expect the calls to come in.

    So it sounds like a http outbound gateway is what I have to use. However, since it is a outbound gateway which gets triggered based on the availability of a message in a channel, I have to artificially put a dummy message in a channel to trigger the outbound http gateway to get a message in, this way:

    Code:
    	<int:channel id="quakeinfotrigger.channel"></int:channel>	
    	<int:inbound-channel-adapter channel="quakeinfotrigger.channel" expression="@triggerChannelAdapter.trigger()">
    		<int:poller fixed-delay="60000"></int:poller>
    	</int:inbound-channel-adapter>
    
    	<int:channel id="quakeinfo.channel">
    		<int:queue capacity="10"/>
    	</int:channel>
    	<int-http:outbound-gateway id="quakerHttpGateway"
    	    request-channel="quakeinfotrigger.channel"
    	    url="http://earthquake.usgs.gov/earthquakes/feed/geojson/all/hour"
    	    http-method="GET"
    	    expected-response-type="java.lang.String"
    	    charset="UTF-8"
    	    reply-timeout="5000"
    	    reply-channel="quakeinfo.channel">	    
    	</int-http:outbound-gateway>
    So my question is - Is there a better way to do this?
    Last edited by biju.kunjummen; Oct 2nd, 2012, 10:33 AM.

  • #2
    Hi!

    You really go right way!
    However your 'dummy' payload can be like this:
    HTML Code:
    <int:inbound-channel-adapter channel="quakeinfotrigger.channel" expression="''">
    Take care,
    Artem

    Comment


    • #3
      Nice, thanks Artem, that works and avoids needing to create a dummy adapter also.

      Comment

      Working...
      X