I want two separate retry policies for a specific consumer. One for HttpRequestException and SocketException, and the other for a custom DatabaseException and unhandled SqlException. I want to do that because I want to have separate exponential retry intervals for both.
I have the following configuration:
cfg.ReceiveEndpoint(
host,
"ExampleQueueName",
ec =>
{
ec.Consumer<ExampleConsumer>(context);
ec.EnablePriority(5);
ec.UseRetry(retryConfig =>
{
// exponential backup in minutes
retryConfig.Intervals(new[] { 1, 2, 4, 8, 16, 32 }.Select(t => TimeSpan.FromSeconds(t)).ToArray());
retryConfig.Handle<HttpRequestException>(x => x.IsTransient());
retryConfig.Handle<SocketException>(x => x.IsTransient());
});
ec.UseRetry(retryConfig =>
{
// exponential backup in seconds
retryConfig.Intervals(new[] { 1, 2, 4, 8, 16, 32 }.Select(t => TimeSpan.FromSeconds(t)).ToArray());
retryConfig.Handle<DatabaseException>(x => x.IsTransient());
retryConfig.Handle<SqlException>(x => x.IsTransient());
});
});
Presently, only the second one is used. The first one appears to be overwritten.
I've also tried configuring second level retries like so:
cfg.ReceiveEndpoint(
host,
"QueueName",
ec =>
{
ec.Consumer<ExampleConsumer>(context, factory =>
{
factory.UseRetry(retryConfig =>
{
// exponential backup in seconds for sql and concurrency exceptions
retryConfig.Intervals(new[] { 1, 2, 4, 8, 16, 32 }.Select(t => TimeSpan.FromSeconds(t)).ToArray());
retryConfig.Handle<DatabaseException>(x => x.IsTransient());
retryConfig.Handle<SqlException>(x => x.IsTransient());
});
});
ec.EnablePriority(5);
ec.UseRetry(retryConfig =>
{
// exponential backup in minutes for http request exceptions
retryConfig.Intervals(new[] { 1, 2, 4, 8, 16, 32 }.Select(t => TimeSpan.FromSeconds(t)).ToArray());
retryConfig.Handle<DatabaseException>(x => x.IsTransient());
retryConfig.Handle<SqlException>(x => x.IsTransient());
});
});
But that doesn't seem to work either. Does any know how I can apply different retry intervals for different exception types?
MassTransit builds everything as a pipeline, and the order of the filters matters. Rewriting your example above should fix the issue (all I did was move the Consumer to the end).
cfg.ReceiveEndpoint("ExampleQueueName", ec =>
{
ec.EnablePriority(5);
ec.UseMessageRetry(r =>
{
r.Intervals(new[] { 1, 2, 4, 8, 16, 32 }.Select(t => TimeSpan.FromSeconds(t)).ToArray());
r.Handle<HttpRequestException>(x => x.IsTransient());
r.Handle<SocketException>(x => x.IsTransient());
});
ec.UseMessageRetry(r =>
{
r.Intervals(new[] { 1, 2, 4, 8, 16, 32 }.Select(t => TimeSpan.FromSeconds(t)).ToArray());
r.Handle<DatabaseException>(x => x.IsTransient());
r.Handle<SqlException>(x => x.IsTransient());
});
ec.Consumer<ExampleConsumer>(context);
});
Related
I want to use some fields from RabbitMQ messages into Logstah Elasticsearch output (like a index name, etc).
If I use [#metadata][rabbitmq_properties][timestamp] in filter it works nice, but not in output statement (config below).
What am I doing wrong?
input {
rabbitmq {
host => "rabbitmq:5672"
user => "user"
password => "password"
queue => "queue "
durable => true
prefetch_count => 1
threads => 3
ack => true
metadata_enabled => true
}
}
filter {
if [#metadata][rabbitmq_properties][timestamp] {
date {
match => ["[#metadata][rabbitmq_properties][timestamp]", "UNIX"]
}
}
}
output {
elasticsearch {
hosts => ['http://elasticsearch:9200']
index => "%{[#metadata][rabbitmq_properties][IndexName]}_%{+YYYY.MM.dd}"
}
stdout {codec => rubydebug}
}
check with replace function as mentioned below.
input {
rabbitmq {
host => "rabbitmq:5672"
user => "user"
password => "password"
queue => "queue "
durable => true
prefetch_count => 1
threads => 3
ack => true
metadata_enabled => true
}
}
filter {
if [#metadata][rabbitmq_properties][timestamp] {
date {
match => ["[#metadata][rabbitmq_properties][timestamp]", "UNIX"]
}
}
mutate {
replace => {
"[#metadata][index]" => "%{[#metadata][rabbitmq_properties][IndexName]}_%{+YYYY.MM.dd}"
}
}
}
output {
elasticsearch {
hosts => ['http://elasticsearch:9200']
index => "%{[#metadata][index]}_%{+YYYY.MM.dd}"
}
stdout {codec => rubydebug}
}
I am wondering why my condition is not working. If I remove the password_reset then it work, but when I include, it won't work again. Please see my code below:
$requirements = [
'username' => $request->input('username'),
'password' => $request->input('password'),
'deleted' => 0,
'status' => 1,
'confirmed' => 1,
'password_reset' => 0
];
if(Auth::attempt($requirements)){
dd('success');
} else{
return redirect()->back()->with('danger', 'Oops! Login Failed.');
}
Trying to Use html to pdf extension in YII . After placing all the required files in its places and including the following code in config:
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf' => array(
'librarySourcePath' => 'application.vendor.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf', // the literal class filename to be loaded from the vendors folder
/*'defaultParams' => array( // More info: http://mpdf1.com/manual/index.php?tid=184
'mode' => '', // This parameter specifies the mode of the new document.
'format' => 'A4', // format A4, A5, ...
'default_font_size' => 0, // Sets the default document font size in points (pt)
'default_font' => '', // Sets the default font-family for the new document.
'mgl' => 15, // margin_left. Sets the page margins for the new document.
'mgr' => 15, // margin_right
'mgt' => 16, // margin_top
'mgb' => 16, // margin_bottom
'mgh' => 9, // margin_header
'mgf' => 9, // margin_footer
'orientation' => 'P', // landscape or portrait orientation
)*/
),
'HTML2PDF' => array(
'librarySourcePath' => 'application.vendor.html2pdf.*',
'classFile' => 'html2pdf.class.php', // For adding to Yii::$classMap
/*'defaultParams' => array( // More info: http://wiki.spipu.net/doku.php?id=html2pdf:en:v4:accueil
'orientation' => 'P', // landscape or portrait orientation
'format' => 'A4', // format A4, A5, ...
'language' => 'en', // language: fr, en, it ...
'unicode' => true, // TRUE means clustering the input text IS unicode (default = true)
'encoding' => 'UTF-8', // charset encoding; Default is UTF-8
'marges' => array(5, 5, 5, 8), // margins by default, in order (left, top, right, bottom)
)*/
)
),
),
I get the following error
ERROR: include(HTML2PDF_locale.php): failed to open stream: No such
file or directory
It could be a namespace issue, add namespace app/ext .
I am trying to write an application in cycle js using the cycle js http driver. Here's the response subscriptions for the call which is getting fired 3 times.
One subscription i need in the login page and another in the main. It's like:
login:
const response$ = http
.filter(res => res.request.url.indexOf("test/v3/users/login")>=0)
.flatMap(x => x.catch(err => Observable.just({err})))
.map(response => {
if(isErr(response)){
return extractError(response)
}
else{
return extractResponse(response)
}
})
const x$ = response$.filter(x => x.status === "success").map(x => {return {key: "b", value: x.session.b_token}})
main function:
const loginStorage$ = sources.http
.filter(res => res.request.url.indexOf("test/v3/users/login")>=0)
.flatMap(x => x.catch(err => Observable.just({err})))
.map(response => {
if(isErr(response)){
return extractError(response)
}
else{
return extractResponse(response)
}
})
.filter(x => x.status === 'success').map(x => {return {key: "a", value: x.session.id}})
Any help appreciated!!
We have a state in our defects called "Need More Information". I would like to create a graph over time of how many defects are in that state at any particular period of time.
I think I can get the info to do that with the Lookback API with the following query:
my $find = {
State => 'Need More Information',
'_PreviousValues.State' => {'$ne' => 'Need More Information'},
_TypeHierarchy => -51006, # defect
_ValidFrom => {
'$gte' => '2012-09-01TZ',
'$lt' => '2012-10-23TZ',
}
I thought that would give me back a list of all defect snapshots where the defect was transitioning into "Need More Information" state, but it does not (seems to list everything that was ever in "Need More Information" state.
Technically what I need is a query that lists snapshots of any defects transitioning either TO OR FROM the "Need More Information" state, but since this simpler one did not seem to work as I expected, I thought I would ask first why the query above did not work the way I expected.
The "Generated Query" in the header that comes back is:
'fields' => 1,
'skip' => 0,
'limit' => 100,
'find' => {
'_TypeHierarchy' => -51006,
'_ValidFrom' => {
'$gte' => '2012-09-01T00:00:00.000Z',
'$lt' => '2012-10-23T00:00:00.000Z'
},
'_PreviousValues.State' => {
'$in' => [
undef,
5792599066,
5792599067,
5792599065,
5792599070,
5792599071,
5792599068,
5792599073,
5792599072,
5792599075,
5792599077,
5792599076,
5792599078,
3631859989,
3631859988,
3631859987,
3631859986
]
},
'State' => {
'$in' => [
4384150044
]
}
}
};
I tried leveraging the $nin clause and had success with it. You might try adjusting your query to resemble something like this:
find: {
_Type: 'Defect',
State: 'Need More Information',
'_PreviousValues.State': {
$in: [
'Submitted', 'Open', 'Fixed', 'Closed'
]
},
etc...
}