Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Microservices Hystrix issue  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
What does your springboot configuration class look like?
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!