• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Microservices Hystrix issue

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using Spring boot for development . Currently i am testing hystrix fallback mechanism . Issue is when ever i tried to make a rest call control is immediately falling back to fallback method.Below is my code .If i removed Hystrix command it is working fine.

Kindly help on this

package com.ibm.oilngas.controllers;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;


@Service

public class FallBackService {

private final RestTemplate restTemplate;

public FallBackService(RestTemplate rest) {
this.restTemplate = rest;
}
@HystrixCommand(fallbackMethod = "plantactivityfallback")
public List<PlantactivityBean> readingList() {

ResponseEntity<List<PlantactivityBean>> rateResponse = restTemplate.exchange(
"http://localhost:9001/getallplantactivity", HttpMethod.GET, null,
new ParameterizedTypeReference<List<PlantactivityBean>>() {

});




List<PlantactivityBean> rates = rateResponse.getBody();
return rates;
}

public List<PlantactivityBean> plantactivityfallback() {
ArrayList aa = new ArrayList();
aa.add("Service is Not avilable Currently !! Please try again!!!");
            return aa;
}
}
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does your springboot configuration class look like?
 
reply
    Bookmark Topic Watch Topic
  • New Topic