[PATCH] [MAMDACPP/ MAMDAJAVA] Update to correct state machine to allow reactivation from state deactivated.


Adrienne Ambrose <AAmbrose@...>
 

TESTING –

Test by putting activate call in the onError callback. A timeout event will cause an error in the activate. 
Putting deactivate / activate call in the onMsg will give also cause an error.

After this patch is applied both scenarios execute correctly. 

 

From c3df745d87f5157065d8122c5bb8111cad15a322 Mon Sep 17 00:00:00 2001

From: A Ambrose <aambrose@...>

Date: Mon, 12 May 2014 12:56:35 +0100

Subject: [PATCH] Update to correct state machine to allow reactivation

from state deactivated. [OMAMA-259] Description - Refactor of Mamda

Subscription methods, to now allow activation call from state

deactivating/deactivated.

 

Signed-off-by: A Ambrose <aambrose@...>

---

mamda/c_cpp/src/cpp/MamdaSubscription.cpp          | 13 +++++++++++++

mamda/java/com/wombat/mamda/MamdaSubscription.java | 18 +++++++++++++++---

2 files changed, 28 insertions(+), 3 deletions(-)

 

diff --git a/mamda/c_cpp/src/cpp/MamdaSubscription.cpp b/mamda/c_cpp/src/cpp/MamdaSubscription.cpp

index 684e73e..4885978 100644

--- a/mamda/c_cpp/src/cpp/MamdaSubscription.cpp

+++ b/mamda/c_cpp/src/cpp/MamdaSubscription.cpp

@@ -281,6 +281,17 @@ namespace Wombat

         {

             mImpl.mMamaSubscription = new MamaSubscription();

         }

+        else

+        {

+            mamaSubscriptionState state = MAMA_SUBSCRIPTION_UNKNOWN;

+            state = mImpl.mMamaSubscription->getState();

+

+            if ((state == MAMA_SUBSCRIPTION_DEACTIVATING) || (state == MAMA_SUBSCRIPTION_DEACTIVATED))

+            {

+                mImpl.mMamaSubscription->activate();

+                return;

+            }

+        }

          

         mImpl.mMamaSubscription->setAppDataType      (mImpl.mMdDataType);

         mImpl.mMamaSubscription->setSubscriptionType (mImpl.mType);

@@ -302,6 +313,8 @@ namespace Wombat

         if (mImpl.mMamaSubscription)

         {

             mImpl.mMamaSubscription->destroy();

+            delete mImpl.mMamaSubscription;

+            mImpl.mMamaSubscription = NULL;

         }   

     }

diff --git a/mamda/java/com/wombat/mamda/MamdaSubscription.java b/mamda/java/com/wombat/mamda/MamdaSubscription.java

index 9a7d1cc..2be1915 100644

--- a/mamda/java/com/wombat/mamda/MamdaSubscription.java

+++ b/mamda/java/com/wombat/mamda/MamdaSubscription.java

@@ -219,9 +219,21 @@ public class MamdaSubscription

     public synchronized void activate ()

     {

         /*Already activated if not null*/

-        if (mSubscription != null) return;        

-      

-        mSubscription = new MamaSubscription ();

+        if (mSubscription != null)

+        {

+            MamaSubscriptionState state = mSubscription.getState();

+

+            if((state == MamaSubscriptionState.MAMA_SUBSCRIPTION_DEACTIVATING) ||

+                (state == MamaSubscriptionState.MAMA_SUBSCRIPTION_DEACTIVATED))

+            {

+                mSubscription.activate ();

+                return;

+            }

+        }

+        else

+        {        

+            mSubscription = new MamaSubscription ();

+        }

         mSubscription.setSubscriptionType (mType);

         mSubscription.setServiceLevel     (mServiceLevel,mServiceLevelOpt);

--

1.8.3.1

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.