I am using the following properties for my hystrix implementation
#HystrixCommand(fallbackMethod = "circuitBreakerFallbackForGet",commandProperties = {
#HystrixProperty(name = "execution.isolation.strategy", value = "THREAD"),
#HystrixProperty(name = "execution.timeout.enabled", value = "false"),
#HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "10000"),
#HystrixProperty(name = "execution.isolation.thread.interruptOnTimeout", value = "false"),
#HystrixProperty(name = "fallback.enabled", value = "true"),
#HystrixProperty(name = "circuitBreaker.enabled", value = "false"),
#HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "100"),
#HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000"),
#HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "50"),
#HystrixProperty(name = "circuitBreaker.forceOpen", value = "false"),
#HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "20000"),
#HystrixProperty(name = "circuitBreaker.forceClosed", value = "false") }, commandKey = "getAccountInfo", groupKey = "getAccountInfo", threadPoolKey = "thread-pool-core-service", threadPoolProperties = {
#HystrixProperty(name = "coreSize", value = "10") })
After adding this code my microservices generally fails and its goes to the fallback method that i have added . I understand that only three values make sense in that and they are
metrics.rollingStats.timeInMilliseconds -- this will be the time limit for the hystrix for considering the failure calculation.
circuitBreaker.errorThresholdPercentage -- this is the percantage of failures that should happen for fallback to come into picture.
circuitBreaker.requestVolumeThreshold -- this is the number of request volume that should come atleast in the mentioned timeinMilliseconds then only hystrix will come into picture.
Also I'm providing seperate commandkey and groupkey for every method where i have added hystrix.
Please suggest how to manage so that it works as expected.
Related
You know that there is a stream find-all method under JpaRepository:
#QueryHints(value = {
#QueryHint(name = HINT_FETCH_SIZE, value = ""),
#QueryHint(name = HINT_CACHEABLE, value = "false"),
#QueryHint(name = HINT_READONLY, value = "true"),
})
Stream<PaidKeyword> findAllBy();
Can I handle same/similar method for Neo4jRepository?
My purpose is so simple. To fetch all data (~5M) partially and effectively. Otherwise, I got timeout errors...
I'm involved with a project to convert our spring-boot codebase from Hystrix to Resilience4J. Some of the conversions have been straightforward but there are some more complicated ones that I'm not sure how to convert.
We have classes that have annotations like this:
#DefaultProperties(groupKey = "HistrixCircuitDefaultGroupKey",
commandProperties = {
#HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "10000"),
#HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "5000"),
#HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "20"),
#HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "50") },
threadPoolKey = "client-tp",
threadPoolProperties = {
#HystrixProperty(name = "coreSize", value = "55")
})
Then elsewhere in the class the methods are annotated with things like:
#HystrixCommand(commandKey = "postContact")
Can someone give me advice on how to convert that into the equivalent Resilence4J code?
I am trying to build a rest-api for a movie-review website. The movie model contains a cast-field which is a list-field, when using ModelViewSets one can't POST ListFields through HTML, so I set blank = true for all list-fields thinking that I'll make a raw PATCH request to update the blank fields, but I am unable to do so.
models.py
class Movie(models.Model):
movie_name = models.CharField(max_length = 100, unique = True)
release_date = models.DateField(blank = True)
description = models.TextField(max_length = 500)
movie_poster = models.ImageField(blank = True)
directors = ListCharField(
base_field = models.CharField(max_length = 500),
max_length = 6 * 500,
blank = True
)
trailer_url = models.URLField()
cast = ListCharField(
base_field = models.CharField(max_length = 225),
max_length = 11 * 225,
blank = True
)
genre = ListCharField(
base_field = models.CharField(max_length = 225),
max_length = 11 * 255,
blank = True
)
avg_rating = models.FloatField(validators = [MinValueValidator(0), MaxValueValidator(5)])
country = models.CharField(max_length = 100)
language = models.CharField(max_length = 100)
budget = models.BigIntegerField(blank = True)
revenue = models.BigIntegerField(blank = True)
runtime = models.DurationField(blank = True)
Serializer
class MovieSerializer(ModelSerializer):
cast = ListField(
child = CharField(required = False), required = False,
min_length = 0
)
genre = ListField(
child = CharField(required = False), required = False,
min_length = 0
)
directors = ListField(
child = CharField(required = False), required = False,
min_length = 0
)
class Meta:
model = Movie
fields = '__all__'
I used djano-mysql for adding the ListCharField field-type.
https://i.stack.imgur.com/sC6Vw.png [The data without list field values]
https://i.stack.imgur.com/W3xea.png [request I tried to make]
https://i.stack.imgur.com/OPeJn.png [response that I received]
Original put request which resulted in an error response
https://i.stack.imgur.com/W3xea.png
The request had some trailing commas, due to which the API expected more values.
Here's the correct request-content -
{
"cast": [
"aamir",
"sakshi"
],
"genre": [
"biopic"
],
"directors": [
"nitesh tiwari"
]
}
How do I query objects by attribute (instead of 'Filter Keys') using the Genesys Platform SDK?
Endpoint endpoint = new Endpoint("DEV", "the host", 12020);
endpoint.ServicePrincipalName = "the host/the principle";
_confServerProtocol = new ConfServerProtocol(endpoint);
_confServerProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE;
_confServerProtocol.ClientName = "default";
_confServerProtocol.UserName = "the userid";
_confServerProtocol.Open();
IConfService confService = ConfServiceFactory.CreateConfService(_confServerProtocol);
CfgPersonQuery query = new CfgPersonQuery();
// Need to filter based on an Attribute Value (specifically externalID)
var foo = confService.RetrieveMultipleObjects<CfgPerson>(query);
This worked for me:
CfgXPathBasedQuery query = new CfgXPathBasedQuery(confService, CfgObjectType.CFGPerson, "CfgPerson[#externalID='the value']");
Use below:
Uri uri = new Uri("tcp://Host:Port");
Endpoint endpoint = new Endpoint(Guid.NewGuid().ToString(), uri);
ConfServerProtocol confProtocol = new ConfServerProtocol(endpoint);
confProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE;
confProtocol.ClientName = "default";
confProtocol.UserName = "xxxxxx";
confProtocol.UserPassword = "xxxxxx";
//Channel Open
confProtocol.Open();
IConfService confService = ConfServiceFactory.CreateConfService(confProtocol);
CfgPersonQuery query = new CfgPersonQuery();
query.UserName = "AgentID";
CfgPerson person = confService.RetrieveObjects<CfgPerson>(query);
string ExtID = person.ExternalId;
Note: In this way, Filtering is not possible through ExternalId.
I have this linq statement that returns result and i wanted to add the specifications of how many items are displayed per page. I know the default is 10 per page how can i change it to 40?
var _roster = DataCBase.StoredProcedures.GetUser<Users>(userID, r => new Users
{
Name = RosterColumnMap.Name(r),
Email = RosterColumnMap.Email(r)
});
Get User
public virtual IEnumerable<T> GetUser<T>(int userId, Func<IDataRecord, T> modelBinder, int resultsPerPage = 10, int pageNumber = 1)
{
if (userId < 1)
throw new NullReferenceException("The sectionId cannot be null, when retreiving an element");
if (resultsPerPage < 1)
resultsPerPage = 1; // enforce bare minimum result set
if (pageNumber < 1)
pageNumber = 1; // enforce one-based page numbering
SqlCommand _command = new SqlCommand("dbo.GetUser");
_command.CommandType = CommandType.StoredProcedure;
_command.Parameters.Add(new SqlParameter { ParameterName = "userId", SqlDbType = SqlDbType.Int, Value = userId });
_command.Parameters.Add(new SqlParameter { ParameterName = "resultsPerPage", SqlDbType = SqlDbType.Int, Value = resultsPerPage });
_command.Parameters.Add(new SqlParameter { ParameterName = "pageNumber", SqlDbType = SqlDbType.Int, Value = pageNumber });
return DbInstance.ExecuteAs<T>(_command, modelBinder);
}
Neither Linq nor entity framework have any default number of records 'per page'. But since your GetUser function includes a resultsPerPage parameter, you can just do this:
var _roster = DataCBase.StoredProcedures.GetUser<Users>(userID, r => new Users
{
Name = RosterColumnMap.Name(r),
Email = RosterColumnMap.Email(r)
}, 40);
To limit the number of results in Linq use the the Enumerable.Take method:
var _roster = DataCBase.StoredProcedures.GetUser<Users>(userID, r => new Users
{
Name = RosterColumnMap.Name(r),
Email = RosterColumnMap.Email(r)
}).Take(40);