title: Set Hangfire succeeded job expiry attribute not working
body: <p>I am using Hangfire to do jobs, and I'd like to change the behaviour that succeeded jobs are deleted from the database after a day - I'd like them to be stored for a year.</p>
  
  <p>Following the instructions in this <a href="https://discuss.hangfire.io/t/how-to-configure-the-retention-time-of-job/34" rel="noreferrer">thread</a>, which is the same as in <a href="https://stackoverflow.com/questions/34450884/keep-history-of-jobs-executed-for-more-than-1-day-in-hangfire">this SO question</a>, I have created a class:</p>
  
  <pre><code>public class OneYearExpirationTimeAttribute : JobFilterAttribute, IApplyStateFilter
  {
      public void OnStateUnapplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
      {
          context.JobExpirationTimeout = TimeSpan.FromDays(365);
      }
  
      public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
      {
          context.JobExpirationTimeout = TimeSpan.FromDays(365);
      }
  }
  </code></pre>
  
  <p>and I register it in my Asp.net web api startup class as a global filter:</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          // ... other stuff here ...
          GlobalJobFilters.Filters.Add(new OneYearExpirationTimeAttribute());
          GlobalConfiguration.Configuration.UseSqlServerStorage("HangFireDBConnection");
          app.UseHangfireDashboard();
      }
  }
  </code></pre>
  
  <p>The web api is the place where jobs are posted (i.e., the call to <code>BackgroundJob.Enqueue(() =&gt; ...)</code> happens). I have not changed the configuration of the clients that do the actual jobs.</p>
  
  <p>If I now post a job and it succeeds, it still has a expiry of one day as you can see in the screenshot, which shows both the dashboard and the entry in the HangfireDb,</p>
  
  <p><a href="https://stackoverflow.com/questions/34450884/keep-history-of-jobs-executed-for-more-than-1-day-in-hangfire"><img src="https://i.stack.imgur.com/vRyzW.png" alt="enter image description here"></a></p>
  
  <p>What am I doing wrong or what am I missing?</p>