skip to Main Content

I have implemented “Apache Geode” into console application and win forms successfully.

I have converted this solution into a “Class Library”.

When I call this class library to set up a “Cache Listener” it works on the console app, but not in asp.net (MVC) app.

I’ve tried calling this dll inside a MVC HomeController inside Index() method.
This is what’s inside the dll:

    internal void RegisterQuoteListener(Cache c, string quoteReqId, Action<string, Quote> AddQuote,
                                        Action<string, QuoteAcknowledgement> AddQuoteAck,
                                        Action<string, QuoteCancel> AddQuoteCancel)
    {
        List<string> s = new List<string>();
        s.Add(quoteReqId);

        IRegion<string, Object> q = c.GetRegion<string, Object>("quote");

        try
        {
            q.GetSubscriptionService().RegisterKeys(s);
            q.AttributesMutator.SetCacheListener(new LQuote<string, Object>(this, AddQuote, AddQuoteAck, AddQuoteCancel));
        }
        catch (Exception ex)
        {
            new ApplicationException("Can't register key: " + quoteReqId, ex);
        }
    }



    public override void AfterCreate(EntryEvent<TKey, TVal> ev)
    {
        HandleCreateAndUpdate(ev);
    }

The way it should work is you set up a listener for a specific key, then when any message comes to that region with the same key, it should fire an event called
“public override void AfterCreate(EntryEvent ev)”

Is there an MVC limitation that differs from a console application in this example?

I can provide more information per your questions.

EDIT1

Inside MVC HomeController I call this helper like this:

 public ActionResult Index()
    {
        //var a = new Geode().QuoteRequestWrapper("EUR", "GBP", "GBP", DateTime.Now.Date.AddDays(14), 10, "any reference", true);

        //Create Instance
        Geode geode = new Geode();

        //Initialize Cache
        geode.InitializeCache(ip, port, pool);

        //Send Geode message
        geode.GeodePut("region1", Guid.NewGuid().ToString().Substring(0, 8).ToUpper(), "Starting Geode Test");

        //Quote request - single
        geode.QuoteRequest("EUR", "GBP", "GBP", DateTime.Now.Date.AddDays(14), 10, "any reference", true);
        return View();
}

inside geode.QuoteRequest it sets up a “Listener” which should fire an event into a method from the initialized cache. But the action is never called.

2

Answers


  1. Chosen as BEST ANSWER

    Here is the answer: How can I make the "CacheListenerAdapter" work in ASP.NET?

    If you are using a version of GemFire Native Client less than 10.0.0 then you are likely running into an issue with AppDomain in ASP.NET. While many AppDomain issues are mitigated in 9.x some are just not possible to address in that version. Updating to the latest 10.x should address your issue.


  2. How exactly do you call that dll in the Controller? the controller is not a singleton, a new instance will be created on each request so if you are storing an instance of your helper class on a property for the controller then your setup wont be persisted.

    Ideally you would use a DI container that can inject a singleton instance of your helper class into the controllers. You could also try using a static parameter.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search