[PATCH 5/7] Update MamaTransportTopicListener to return Topic.


Gary Molloy <GMolloy@...>
 

Testing
This is not OS dependant .
This applies to JAVA only.

This can only be tested on a middleware that provided topic callbacks.

 

Run the attached MamaProxy.java test application and then subscribe to your mamaproxy with a valid symbol.  For example:

 

mamaproxy:
java MamaProxy -ms wmw -mp wmw -tports tcp_sub -tportp tcp_sub -s SPY -SS CTA -SP MAMA_PROXY

mamalisten:
java MamaListen -S MAMA_PROXY -tport tcp_sub -s SPY -dict_tport tcp_sub

 

You can expect to see the following:

Received New Request: SPY
TRANSPORT TOPIC SUBSCRIBE!
for the topic : MAMA_PROXY.SPY

 

 

 

From 02457a32729c28c8a3ac150b613ce7e91c1b9e24 Mon Sep 17 00:00:00 2001

From: Gary Molloy <gmolloy@...>

Date: Mon, 23 Jun 2014 16:22:42 +0100

Subject: [PATCH 5/7] Update MamaTransportTopicListener to return Topic.

 

[OMAMA-266]

 

Description - Topic was not available from the MamaTransportTopicListener in JAVA. 

The callbacks onTopicSubscribe and onTopicUnsubscribe were returning a (short) "cause" which was not useful.

2 Further callbacks were added which do provide the topic.

The old versions were left for backwards compatibility.

 

Signed-off-by: Gary Molloy <gmolloy@...>

---

mama/jni/src/c/mamajniutils.h                      |  6 ++-

mama/jni/src/c/mamatransportjni.c                  | 60 ++++++++++++++++------

mama/jni/src/com/wombat/mama/MamaTransport.java    | 18 +++++++

.../wombat/mama/MamaTransportTopicListener.java    | 37 +++++++++++++

4 files changed, 104 insertions(+), 17 deletions(-)

 

diff --git a/mama/jni/src/c/mamajniutils.h b/mama/jni/src/c/mamajniutils.h

index b01b89c..02dd6c8 100644

--- a/mama/jni/src/c/mamajniutils.h

+++ b/mama/jni/src/c/mamajniutils.h

@@ -49,8 +49,10 @@

 /*Constants for the MamaTransportTopicListener Java class*/

#define UTILS_TRANSPORT_TOPIC_LISTENER_CLASS_NAME "com/wombat/mama/MamaTransportTopicListener"

-#define UTILS_TTL_ON_TOPIC_SUBSCRIBE "(SLjava/lang/Object;)V"

-#define UTILS_TTL_ON_TOPIC_UNSUBSCRIBE "(SLjava/lang/Object;)V"

+#define UTILS_TTL_ON_TOPIC_SUBSCRIBE "(Ljava/lang/String;Ljava/lang/Object;)V"

+#define UTILS_TTL_ON_TOPIC_UNSUBSCRIBE "(Ljava/lang/String;Ljava/lang/Object;)V"

+#define UTILS_TTL_ORIG_ON_TOPIC_SUBSCRIBE "(SLjava/lang/Object;)V"

+#define UTILS_TTL_ORIG_ON_TOPIC_UNSUBSCRIBE "(SLjava/lang/Object;)V"

 /*Constants for the Colleciton interface in Java*/

#define UTILS_ARRAYLIST_CLASS_NAME "java/util/ArrayList"

diff --git a/mama/jni/src/c/mamatransportjni.c b/mama/jni/src/c/mamatransportjni.c

index 989188a..5ae23bf 100644

--- a/mama/jni/src/c/mamatransportjni.c

+++ b/mama/jni/src/c/mamatransportjni.c

@@ -87,8 +87,10 @@ static jmethodID    transportListenerOnNamingServiceConnectId_g     =   NULL;

static jmethodID    transportListenerOnNamingServiceDisconnectId_g  =   NULL;

 /*Method ids for the MamaTransportTopicListener callback*/

-static jmethodID    transportTopicListenerOnTopicSubscribeId_g    =   NULL;

-static jmethodID    transportTopicListenerOnTopicUnsubscribeId_g  =   NULL;

+static jmethodID    transportTopicListenerOnTopicSubscribeId_g        =   NULL;

+static jmethodID    transportTopicListenerOnTopicUnsubscribeId_g      =   NULL;

+static jmethodID    transportTopicListenerOrigOnTopicSubscribeId_g    =   NULL;

+static jmethodID    transportTopicListenerOrigOnTopicUnsubscribeId_g  =   NULL;

 /* Pointer field of the bridge */

extern  jfieldID    bridgePointerFieldId_g;

@@ -107,11 +109,11 @@ mamaTransportListenerCB( mamaTransport        tport,

 static void

MAMACALLTYPE

-mamaTransportTopicListenerCB( mamaTransport        tport,

-                              mamaTransportEvent   event,

-                              short                cause,

-                              const void*          platformInfo,

-                              void*                closure);

+mamaTransportTopicListenerCB( mamaTransport             tport,

+                              mamaTransportTopicEvent   transportTopicEvent,

+                              const char*               topic,

+                              const void*               platformInfo,

+                              void*                     closure);

 /**

  * This function will obtain a mamaConnection pointer from the supplied platform info and

@@ -662,6 +664,24 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaTransport_initIDs

         return;

     }

+    transportTopicListenerOrigOnTopicSubscribeId_g = (*env)->GetMethodID(env,

+                        mamaTransportTopicListenerClass,"onTopicSubscribe",

+                        UTILS_TTL_ORIG_ON_TOPIC_SUBSCRIBE);

+    if(!transportTopicListenerOrigOnTopicSubscribeId_g)

+    {   

+        (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

+        return;

+    }

+

+    transportTopicListenerOrigOnTopicUnsubscribeId_g = (*env)->GetMethodID(env,

+                        mamaTransportTopicListenerClass,"onTopicUnsubscribe",

+                        UTILS_TTL_ORIG_ON_TOPIC_UNSUBSCRIBE);

+    if(!transportTopicListenerOrigOnTopicUnsubscribeId_g)

+    {  

+        (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

+        return;

+    }

+

    (*env)->DeleteLocalRef(env, mamaTransportListenerClass);

    (*env)->DeleteLocalRef(env, mamaTransportListenerClass);

    (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

@@ -750,7 +770,7 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaTransport_nativeAddTopicListener

                                                               if(NULL != closure->mTopicCallback)

                                                               {

                                                                               /* Install the transport topic callback. */

-                                                                              ret = mamaTransport_setTransportTopicCallback(transport, (mamaTransportCB)mamaTransportTopicListenerCB, (void *)closure);

+                                                                             ret = mamaTransport_setTransportTopicCallback(transport, (mamaTransportTopicCB)mamaTransportTopicListenerCB, (void *)closure);

                                                               }

             }

         }

@@ -1015,10 +1035,10 @@ void MAMACALLTYPE mamaTransportListenerCB( mamaTransport      tport,

}

 void MAMACALLTYPE mamaTransportTopicListenerCB( mamaTransport      tport,

-                             mamaTransportEvent transportEvent,

-                             short              cause,

-                             const void*        platformInfo,

-                             void*              closure )

+                                                mamaTransportTopicEvent transportTopicEvent,

+                                                const char*        topic,

+                                                const void*        platformInfo,

+                                                void*              closure )

{

     /* Get the impl from the closure. */

     transportListenerClosure *closureImpl = (transportListenerClosure *)closure;

@@ -1034,14 +1054,24 @@ void MAMACALLTYPE mamaTransportTopicListenerCB( mamaTransport      tport,

              */

             jobject connection = mamaTransportImpl_getConnectionObject(env, platformInfo, closureImpl);

+            /* Convert the C-string topic into a java string. */

+            jstring cTopic = (*env)->NewStringUTF(env, topic);

+

+            /* cause will be used for backward compatibility */

+            short cause = 0;

+

             /* Check the type of transport event. */

-            switch (transportEvent)

+            switch (transportTopicEvent)

             {

                 case MAMA_TRANSPORT_TOPIC_SUBSCRIBED:

-                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicSubscribeId_g, cause, connection);

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicSubscribeId_g, cTopic, connection);

+                    /* Call the Original callback to maintain backward compatibility */

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOrigOnTopicSubscribeId_g, cause, connection);

                     break;

                 case MAMA_TRANSPORT_TOPIC_UNSUBSCRIBED:

-                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicUnsubscribeId_g, cause, connection);

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicUnsubscribeId_g, cTopic, connection);

+                    /* Call the Original callback to maintain backward compatibility */

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOrigOnTopicUnsubscribeId_g, cause, connection);

                     break;

             }       

 

diff --git a/mama/jni/src/com/wombat/mama/MamaTransport.java b/mama/jni/src/com/wombat/mama/MamaTransport.java

index 5fde5ee..aef2282 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransport.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransport.java

@@ -179,6 +179,24 @@ public class MamaTransport

         /* Interface Implementations. */

         /* ****************************************************** */

+        public void onTopicSubscribe(String topic, final Object platformInfo)

+        {

+            /* Call the client topic listener if it has been provided. */

+            if(null != mClientTopicListener)

+            {

+                mClientTopicListener.onTopicSubscribe(topic, platformInfo);

+            }

+        }

+

+        public void onTopicUnsubscribe(String topic, final Object platformInfo)

+        {

+            /* Call the client topic listener if it has been provided. */

+            if(null != mClientTopicListener)

+            {

+                mClientTopicListener.onTopicUnsubscribe(topic, platformInfo);

+            }

+        }

+

         public void onTopicSubscribe(short cause, final Object platformInfo)

         {

             /* Call the client topic listener if it has been provided. */

diff --git a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

index a8d683f..34d1850 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

@@ -26,6 +26,43 @@ public class MamaTransportTopicListener

     /**

      * Invoked when a topic is subscribed to

      *

+     * @param topic The topic of the topic subscription

+     * @param platformInfo Info associated with the topic subscription

+     *

+     * The topic and platformInfo are supplied only by some middlewares.

+     * The information provided by platformInfo is middleware specific.

+     * The following middlewares are supported:

+     *

+     * tibrv: provides the String object version of the tibrv advisory message

+     * Wombat Middleware

+     */

+    public void onTopicSubscribe(String topic, final Object platformInfo)

+    {

+        return;

+    }

+

+    /**

+     * Invoked when a topic is unsubscribed to

+     *

+     * @param topic The topic of the topic unsubscription

+     * @param platformInfo Info associated with the topic unsubscription

+     *

+     * The topic and platformInfo are supplied only by some middlewares.

+     * The information provided by platformInfo is middleware specific.

+     * The following middlewares are supported:

+     *

+     * tibrv: provides the String object version of the tibrv advisory message

+     * Wombat Middleware

+     */

+    public void onTopicUnsubscribe(String topic, final Object platformInfo)

+    {

+        return;

+    }

+

+    /*  Original callbacks for backward compatibility  */

+    /**

+     * Invoked when a topic is subscribed to

+     *

      * @param cause The cause of the topic subscription

      * @param platformInfo Info associated with the topic subscription

      *

--

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.


Gary Molloy <GMolloy@...>
 

Update to MamaTransportTopicListener.

 

Marked the old onTopicSubscribe and onTopicUnsubscribe functions as deprecated – missed from the previous patch “0005-Update-MamaTransportTopicListener-to-return-Topic.patch”

 

 

 

From fcb14ad28fc6708a40b5872c4df5b07f2ceb6570 Mon Sep 17 00:00:00 2001

From: Gary Molloy <gmolloy@...>

Date: Tue, 24 Jun 2014 15:59:40 +0100

Subject: [PATCH 2/2] Update to MamaTransportTopicListener to mark old

functions as deprecated.

 

[OMAMA-266]

 

Update to existing patch.  Marked the old onTopicSubscribe and onTopicUnsubscribe functions as deprecated.

 

Signed-off-by: Gary Molloy <gmolloy@...>

---

mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)

 

diff --git a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

index 34d1850..d5653ae 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

@@ -72,8 +72,10 @@ public class MamaTransportTopicListener

      *

      * tibrv: provides the String object version of the tibrv advisory message

      * Wombat Middleware

+     *

+     * @deprecated use onTopicSubscribe(String topic, final Object platformInfo) instead.

      */

-    public void onTopicSubscribe(short cause, final Object platformInfo)

+    @Deprecated public void onTopicSubscribe(short cause, final Object platformInfo)

     {

         return;

     }

@@ -90,8 +92,10 @@ public class MamaTransportTopicListener

      *

      * tibrv: provides the String object version of the tibrv advisory message

      * Wombat Middleware

+     *

+     * @deprecated use onTopicUnsubscribe(String topic, final Object platformInfo) instead.

      */

-    public void onTopicUnsubscribe(short cause, final Object platformInfo)

+    @Deprecated public void onTopicUnsubscribe(short cause, final Object platformInfo)

     {

         return;

     }

--

1.8.3.1

 

 

From: openmama-dev-bounces@... [mailto:openmama-dev-bounces@...] On Behalf Of Gary Molloy
Sent: 24 June 2014 10:53
To: openmama-dev@...
Subject: [Openmama-dev] [PATCH 5/7] Update MamaTransportTopicListener to return Topic.

 

Testing
This is not OS dependant .
This applies to JAVA only.

This can only be tested on a middleware that provided topic callbacks.

 

Run the attached MamaProxy.java test application and then subscribe to your mamaproxy with a valid symbol.  For example:

 

mamaproxy:
java MamaProxy -ms wmw -mp wmw -tports tcp_sub -tportp tcp_sub -s SPY -SS CTA -SP MAMA_PROXY

mamalisten:
java MamaListen -S MAMA_PROXY -tport tcp_sub -s SPY -dict_tport tcp_sub

 

You can expect to see the following:

Received New Request: SPY
TRANSPORT TOPIC SUBSCRIBE!
for the topic : MAMA_PROXY.SPY

 

 

 

From 02457a32729c28c8a3ac150b613ce7e91c1b9e24 Mon Sep 17 00:00:00 2001

From: Gary Molloy <gmolloy@...>

Date: Mon, 23 Jun 2014 16:22:42 +0100

Subject: [PATCH 5/7] Update MamaTransportTopicListener to return Topic.

 

[OMAMA-266]

 

Description - Topic was not available from the MamaTransportTopicListener in JAVA. 

The callbacks onTopicSubscribe and onTopicUnsubscribe were returning a (short) "cause" which was not useful.

2 Further callbacks were added which do provide the topic.

The old versions were left for backwards compatibility.

 

Signed-off-by: Gary Molloy <gmolloy@...>

---

mama/jni/src/c/mamajniutils.h                      |  6 ++-

mama/jni/src/c/mamatransportjni.c                  | 60 ++++++++++++++++------

mama/jni/src/com/wombat/mama/MamaTransport.java    | 18 +++++++

.../wombat/mama/MamaTransportTopicListener.java    | 37 +++++++++++++

4 files changed, 104 insertions(+), 17 deletions(-)

 

diff --git a/mama/jni/src/c/mamajniutils.h b/mama/jni/src/c/mamajniutils.h

index b01b89c..02dd6c8 100644

--- a/mama/jni/src/c/mamajniutils.h

+++ b/mama/jni/src/c/mamajniutils.h

@@ -49,8 +49,10 @@

 

 /*Constants for the MamaTransportTopicListener Java class*/

#define UTILS_TRANSPORT_TOPIC_LISTENER_CLASS_NAME "com/wombat/mama/MamaTransportTopicListener"

-#define UTILS_TTL_ON_TOPIC_SUBSCRIBE "(SLjava/lang/Object;)V"

-#define UTILS_TTL_ON_TOPIC_UNSUBSCRIBE "(SLjava/lang/Object;)V"

+#define UTILS_TTL_ON_TOPIC_SUBSCRIBE "(Ljava/lang/String;Ljava/lang/Object;)V"

+#define UTILS_TTL_ON_TOPIC_UNSUBSCRIBE "(Ljava/lang/String;Ljava/lang/Object;)V"

+#define UTILS_TTL_ORIG_ON_TOPIC_SUBSCRIBE "(SLjava/lang/Object;)V"

+#define UTILS_TTL_ORIG_ON_TOPIC_UNSUBSCRIBE "(SLjava/lang/Object;)V"

 

 /*Constants for the Colleciton interface in Java*/

#define UTILS_ARRAYLIST_CLASS_NAME "java/util/ArrayList"

diff --git a/mama/jni/src/c/mamatransportjni.c b/mama/jni/src/c/mamatransportjni.c

index 989188a..5ae23bf 100644

--- a/mama/jni/src/c/mamatransportjni.c

+++ b/mama/jni/src/c/mamatransportjni.c

@@ -87,8 +87,10 @@ static jmethodID    transportListenerOnNamingServiceConnectId_g     =   NULL;

static jmethodID    transportListenerOnNamingServiceDisconnectId_g  =   NULL;

 

 /*Method ids for the MamaTransportTopicListener callback*/

-static jmethodID    transportTopicListenerOnTopicSubscribeId_g    =   NULL;

-static jmethodID    transportTopicListenerOnTopicUnsubscribeId_g  =   NULL;

+static jmethodID    transportTopicListenerOnTopicSubscribeId_g        =   NULL;

+static jmethodID    transportTopicListenerOnTopicUnsubscribeId_g      =   NULL;

+static jmethodID    transportTopicListenerOrigOnTopicSubscribeId_g    =   NULL;

+static jmethodID    transportTopicListenerOrigOnTopicUnsubscribeId_g  =   NULL;

 

 /* Pointer field of the bridge */

extern  jfieldID    bridgePointerFieldId_g;

@@ -107,11 +109,11 @@ mamaTransportListenerCB( mamaTransport        tport,

 

 static void

MAMACALLTYPE

-mamaTransportTopicListenerCB( mamaTransport        tport,

-                              mamaTransportEvent   event,

-                              short                cause,

-                              const void*          platformInfo,

-                              void*                closure);

+mamaTransportTopicListenerCB( mamaTransport             tport,

+                              mamaTransportTopicEvent   transportTopicEvent,

+                              const char*               topic,

+                              const void*               platformInfo,

+                              void*                     closure);

 

 /**

  * This function will obtain a mamaConnection pointer from the supplied platform info and

@@ -662,6 +664,24 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaTransport_initIDs

         return;

     }

 

+    transportTopicListenerOrigOnTopicSubscribeId_g = (*env)->GetMethodID(env,

+                        mamaTransportTopicListenerClass,"onTopicSubscribe",

+                        UTILS_TTL_ORIG_ON_TOPIC_SUBSCRIBE);

+    if(!transportTopicListenerOrigOnTopicSubscribeId_g)

+    {   

+        (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

+        return;

+    }

+

+    transportTopicListenerOrigOnTopicUnsubscribeId_g = (*env)->GetMethodID(env,

+                        mamaTransportTopicListenerClass,"onTopicUnsubscribe",

+                        UTILS_TTL_ORIG_ON_TOPIC_UNSUBSCRIBE);

+    if(!transportTopicListenerOrigOnTopicUnsubscribeId_g)

+    {  

+        (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

+        return;

+    }

+

    (*env)->DeleteLocalRef(env, mamaTransportListenerClass);

    (*env)->DeleteLocalRef(env, mamaTransportListenerClass);

    (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

@@ -750,7 +770,7 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaTransport_nativeAddTopicListener

                                                               if(NULL != closure->mTopicCallback)

                                                               {

                                                                               /* Install the transport topic callback. */

-                                                                              ret = mamaTransport_setTransportTopicCallback(transport, (mamaTransportCB)mamaTransportTopicListenerCB, (void *)closure);

+                                                                             ret = mamaTransport_setTransportTopicCallback(transport, (mamaTransportTopicCB)mamaTransportTopicListenerCB, (void *)closure);

                                                               }

             }

         }

@@ -1015,10 +1035,10 @@ void MAMACALLTYPE mamaTransportListenerCB( mamaTransport      tport,

}

 

 void MAMACALLTYPE mamaTransportTopicListenerCB( mamaTransport      tport,

-                             mamaTransportEvent transportEvent,

-                             short              cause,

-                             const void*        platformInfo,

-                             void*              closure )

+                                                mamaTransportTopicEvent transportTopicEvent,

+                                                const char*        topic,

+                                                const void*        platformInfo,

+                                                void*              closure )

{

     /* Get the impl from the closure. */

     transportListenerClosure *closureImpl = (transportListenerClosure *)closure;

@@ -1034,14 +1054,24 @@ void MAMACALLTYPE mamaTransportTopicListenerCB( mamaTransport      tport,

              */

             jobject connection = mamaTransportImpl_getConnectionObject(env, platformInfo, closureImpl);

 

+            /* Convert the C-string topic into a java string. */

+            jstring cTopic = (*env)->NewStringUTF(env, topic);

+

+            /* cause will be used for backward compatibility */

+            short cause = 0;

+

             /* Check the type of transport event. */

-            switch (transportEvent)

+            switch (transportTopicEvent)

             {

                 case MAMA_TRANSPORT_TOPIC_SUBSCRIBED:

-                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicSubscribeId_g, cause, connection);

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicSubscribeId_g, cTopic, connection);

+                    /* Call the Original callback to maintain backward compatibility */

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOrigOnTopicSubscribeId_g, cause, connection);

                     break;

                 case MAMA_TRANSPORT_TOPIC_UNSUBSCRIBED:

-                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicUnsubscribeId_g, cause, connection);

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicUnsubscribeId_g, cTopic, connection);

+                    /* Call the Original callback to maintain backward compatibility */

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOrigOnTopicUnsubscribeId_g, cause, connection);

                     break;

             }       

 

diff --git a/mama/jni/src/com/wombat/mama/MamaTransport.java b/mama/jni/src/com/wombat/mama/MamaTransport.java

index 5fde5ee..aef2282 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransport.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransport.java

@@ -179,6 +179,24 @@ public class MamaTransport

         /* Interface Implementations. */

         /* ****************************************************** */

 

+        public void onTopicSubscribe(String topic, final Object platformInfo)

+        {

+            /* Call the client topic listener if it has been provided. */

+            if(null != mClientTopicListener)

+            {

+                mClientTopicListener.onTopicSubscribe(topic, platformInfo);

+            }

+        }

+

+        public void onTopicUnsubscribe(String topic, final Object platformInfo)

+        {

+            /* Call the client topic listener if it has been provided. */

+            if(null != mClientTopicListener)

+            {

+                mClientTopicListener.onTopicUnsubscribe(topic, platformInfo);

+            }

+        }

+

         public void onTopicSubscribe(short cause, final Object platformInfo)

         {

             /* Call the client topic listener if it has been provided. */

diff --git a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

index a8d683f..34d1850 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

@@ -26,6 +26,43 @@ public class MamaTransportTopicListener

     /**

      * Invoked when a topic is subscribed to

      *

+     * @param topic The topic of the topic subscription

+     * @param platformInfo Info associated with the topic subscription

+     *

+     * The topic and platformInfo are supplied only by some middlewares.

+     * The information provided by platformInfo is middleware specific.

+     * The following middlewares are supported:

+     *

+     * tibrv: provides the String object version of the tibrv advisory message

+     * Wombat Middleware

+     */

+    public void onTopicSubscribe(String topic, final Object platformInfo)

+    {

+        return;

+    }

+

+    /**

+     * Invoked when a topic is unsubscribed to

+     *

+     * @param topic The topic of the topic unsubscription

+     * @param platformInfo Info associated with the topic unsubscription

+     *

+     * The topic and platformInfo are supplied only by some middlewares.

+     * The information provided by platformInfo is middleware specific.

+     * The following middlewares are supported:

+     *

+     * tibrv: provides the String object version of the tibrv advisory message

+     * Wombat Middleware

+     */

+    public void onTopicUnsubscribe(String topic, final Object platformInfo)

+    {

+        return;

+    }

+

+    /*  Original callbacks for backward compatibility  */

+    /**

+     * Invoked when a topic is subscribed to

+     *

      * @param cause The cause of the topic subscription

      * @param platformInfo Info associated with the topic subscription

      *

--

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.



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.


Damian Maguire <DMaguire@...>
 

Thanks Gary, raised in Bugzilla as BZ135

D

From: Gary Molloy <GMolloy@...>
Date: Tuesday, June 24, 2014 10:53 AM
To: "openmama-dev@..." <openmama-dev@...>
Subject: [Openmama-dev] [PATCH 5/7] Update MamaTransportTopicListener to return Topic.

Testing
This is not OS dependant .
This applies to JAVA only.

This can only be tested on a middleware that provided topic callbacks.

 

Run the attached MamaProxy.java test application and then subscribe to your mamaproxy with a valid symbol.  For example:

 

mamaproxy:
java MamaProxy -ms wmw -mp wmw -tports tcp_sub -tportp tcp_sub -s SPY -SS CTA -SP MAMA_PROXY

mamalisten:
java MamaListen -S MAMA_PROXY -tport tcp_sub -s SPY -dict_tport tcp_sub

 

You can expect to see the following:

Received New Request: SPY
TRANSPORT TOPIC SUBSCRIBE!
for the topic : MAMA_PROXY.SPY

 

 

 

From 02457a32729c28c8a3ac150b613ce7e91c1b9e24 Mon Sep 17 00:00:00 2001

From: Gary Molloy <gmolloy@...>

Date: Mon, 23 Jun 2014 16:22:42 +0100

Subject: [PATCH 5/7] Update MamaTransportTopicListener to return Topic.

 

[OMAMA-266]

 

Description - Topic was not available from the MamaTransportTopicListener in JAVA. 

The callbacks onTopicSubscribe and onTopicUnsubscribe were returning a (short) "cause" which was not useful.

2 Further callbacks were added which do provide the topic.

The old versions were left for backwards compatibility.

 

Signed-off-by: Gary Molloy <gmolloy@...>

---

mama/jni/src/c/mamajniutils.h                      |  6 ++-

mama/jni/src/c/mamatransportjni.c                  | 60 ++++++++++++++++------

mama/jni/src/com/wombat/mama/MamaTransport.java    | 18 +++++++

.../wombat/mama/MamaTransportTopicListener.java    | 37 +++++++++++++

4 files changed, 104 insertions(+), 17 deletions(-)

 

diff --git a/mama/jni/src/c/mamajniutils.h b/mama/jni/src/c/mamajniutils.h

index b01b89c..02dd6c8 100644

--- a/mama/jni/src/c/mamajniutils.h

+++ b/mama/jni/src/c/mamajniutils.h

@@ -49,8 +49,10 @@

 /*Constants for the MamaTransportTopicListener Java class*/

#define UTILS_TRANSPORT_TOPIC_LISTENER_CLASS_NAME "com/wombat/mama/MamaTransportTopicListener"

-#define UTILS_TTL_ON_TOPIC_SUBSCRIBE "(SLjava/lang/Object;)V"

-#define UTILS_TTL_ON_TOPIC_UNSUBSCRIBE "(SLjava/lang/Object;)V"

+#define UTILS_TTL_ON_TOPIC_SUBSCRIBE "(Ljava/lang/String;Ljava/lang/Object;)V"

+#define UTILS_TTL_ON_TOPIC_UNSUBSCRIBE "(Ljava/lang/String;Ljava/lang/Object;)V"

+#define UTILS_TTL_ORIG_ON_TOPIC_SUBSCRIBE "(SLjava/lang/Object;)V"

+#define UTILS_TTL_ORIG_ON_TOPIC_UNSUBSCRIBE "(SLjava/lang/Object;)V"

 /*Constants for the Colleciton interface in Java*/

#define UTILS_ARRAYLIST_CLASS_NAME "java/util/ArrayList"

diff --git a/mama/jni/src/c/mamatransportjni.c b/mama/jni/src/c/mamatransportjni.c

index 989188a..5ae23bf 100644

--- a/mama/jni/src/c/mamatransportjni.c

+++ b/mama/jni/src/c/mamatransportjni.c

@@ -87,8 +87,10 @@ static jmethodID    transportListenerOnNamingServiceConnectId_g     =   NULL;

static jmethodID    transportListenerOnNamingServiceDisconnectId_g  =   NULL;

 /*Method ids for the MamaTransportTopicListener callback*/

-static jmethodID    transportTopicListenerOnTopicSubscribeId_g    =   NULL;

-static jmethodID    transportTopicListenerOnTopicUnsubscribeId_g  =   NULL;

+static jmethodID    transportTopicListenerOnTopicSubscribeId_g        =   NULL;

+static jmethodID    transportTopicListenerOnTopicUnsubscribeId_g      =   NULL;

+static jmethodID    transportTopicListenerOrigOnTopicSubscribeId_g    =   NULL;

+static jmethodID    transportTopicListenerOrigOnTopicUnsubscribeId_g  =   NULL;

 /* Pointer field of the bridge */

extern  jfieldID    bridgePointerFieldId_g;

@@ -107,11 +109,11 @@ mamaTransportListenerCB( mamaTransport        tport,

 static void

MAMACALLTYPE

-mamaTransportTopicListenerCB( mamaTransport        tport,

-                              mamaTransportEvent   event,

-                              short                cause,

-                              const void*          platformInfo,

-                              void*                closure);

+mamaTransportTopicListenerCB( mamaTransport             tport,

+                              mamaTransportTopicEvent   transportTopicEvent,

+                              const char*               topic,

+                              const void*               platformInfo,

+                              void*                     closure);

 /**

  * This function will obtain a mamaConnection pointer from the supplied platform info and

@@ -662,6 +664,24 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaTransport_initIDs

         return;

     }

+    transportTopicListenerOrigOnTopicSubscribeId_g = (*env)->GetMethodID(env,

+                        mamaTransportTopicListenerClass,"onTopicSubscribe",

+                        UTILS_TTL_ORIG_ON_TOPIC_SUBSCRIBE);

+    if(!transportTopicListenerOrigOnTopicSubscribeId_g)

+    {   

+        (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

+        return;

+    }

+

+    transportTopicListenerOrigOnTopicUnsubscribeId_g = (*env)->GetMethodID(env,

+                        mamaTransportTopicListenerClass,"onTopicUnsubscribe",

+                        UTILS_TTL_ORIG_ON_TOPIC_UNSUBSCRIBE);

+    if(!transportTopicListenerOrigOnTopicUnsubscribeId_g)

+    {  

+        (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

+        return;

+    }

+

    (*env)->DeleteLocalRef(env, mamaTransportListenerClass);

    (*env)->DeleteLocalRef(env, mamaTransportListenerClass);

    (*env)->DeleteLocalRef(env, mamaTransportTopicListenerClass);

@@ -750,7 +770,7 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaTransport_nativeAddTopicListener

                                                               if(NULL != closure->mTopicCallback)

                                                               {

                                                                               /* Install the transport topic callback. */

-                                                                              ret = mamaTransport_setTransportTopicCallback(transport, (mamaTransportCB)mamaTransportTopicListenerCB, (void *)closure);

+                                                                             ret = mamaTransport_setTransportTopicCallback(transport, (mamaTransportTopicCB)mamaTransportTopicListenerCB, (void *)closure);

                                                               }

             }

         }

@@ -1015,10 +1035,10 @@ void MAMACALLTYPE mamaTransportListenerCB( mamaTransport      tport,

}

 void MAMACALLTYPE mamaTransportTopicListenerCB( mamaTransport      tport,

-                             mamaTransportEvent transportEvent,

-                             short              cause,

-                             const void*        platformInfo,

-                             void*              closure )

+                                                mamaTransportTopicEvent transportTopicEvent,

+                                                const char*        topic,

+                                                const void*        platformInfo,

+                                                void*              closure )

{

     /* Get the impl from the closure. */

     transportListenerClosure *closureImpl = (transportListenerClosure *)closure;

@@ -1034,14 +1054,24 @@ void MAMACALLTYPE mamaTransportTopicListenerCB( mamaTransport      tport,

              */

             jobject connection = mamaTransportImpl_getConnectionObject(env, platformInfo, closureImpl);

+            /* Convert the C-string topic into a java string. */

+            jstring cTopic = (*env)->NewStringUTF(env, topic);

+

+            /* cause will be used for backward compatibility */

+            short cause = 0;

+

             /* Check the type of transport event. */

-            switch (transportEvent)

+            switch (transportTopicEvent)

             {

                 case MAMA_TRANSPORT_TOPIC_SUBSCRIBED:

-                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicSubscribeId_g, cause, connection);

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicSubscribeId_g, cTopic, connection);

+                    /* Call the Original callback to maintain backward compatibility */

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOrigOnTopicSubscribeId_g, cause, connection);

                     break;

                 case MAMA_TRANSPORT_TOPIC_UNSUBSCRIBED:

-                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicUnsubscribeId_g, cause, connection);

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOnTopicUnsubscribeId_g, cTopic, connection);

+                    /* Call the Original callback to maintain backward compatibility */

+                    (*env)->CallVoidMethod( env, closureImpl->mTopicCallback, transportTopicListenerOrigOnTopicUnsubscribeId_g, cause, connection);

                     break;

             }       

 

diff --git a/mama/jni/src/com/wombat/mama/MamaTransport.java b/mama/jni/src/com/wombat/mama/MamaTransport.java

index 5fde5ee..aef2282 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransport.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransport.java

@@ -179,6 +179,24 @@ public class MamaTransport

         /* Interface Implementations. */

         /* ****************************************************** */

+        public void onTopicSubscribe(String topic, final Object platformInfo)

+        {

+            /* Call the client topic listener if it has been provided. */

+            if(null != mClientTopicListener)

+            {

+                mClientTopicListener.onTopicSubscribe(topic, platformInfo);

+            }

+        }

+

+        public void onTopicUnsubscribe(String topic, final Object platformInfo)

+        {

+            /* Call the client topic listener if it has been provided. */

+            if(null != mClientTopicListener)

+            {

+                mClientTopicListener.onTopicUnsubscribe(topic, platformInfo);

+            }

+        }

+

         public void onTopicSubscribe(short cause, final Object platformInfo)

         {

             /* Call the client topic listener if it has been provided. */

diff --git a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

index a8d683f..34d1850 100644

--- a/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

+++ b/mama/jni/src/com/wombat/mama/MamaTransportTopicListener.java

@@ -26,6 +26,43 @@ public class MamaTransportTopicListener

     /**

      * Invoked when a topic is subscribed to

      *

+     * @param topic The topic of the topic subscription

+     * @param platformInfo Info associated with the topic subscription

+     *

+     * The topic and platformInfo are supplied only by some middlewares.

+     * The information provided by platformInfo is middleware specific.

+     * The following middlewares are supported:

+     *

+     * tibrv: provides the String object version of the tibrv advisory message

+     * Wombat Middleware

+     */

+    public void onTopicSubscribe(String topic, final Object platformInfo)

+    {

+        return;

+    }

+

+    /**

+     * Invoked when a topic is unsubscribed to

+     *

+     * @param topic The topic of the topic unsubscription

+     * @param platformInfo Info associated with the topic unsubscription

+     *

+     * The topic and platformInfo are supplied only by some middlewares.

+     * The information provided by platformInfo is middleware specific.

+     * The following middlewares are supported:

+     *

+     * tibrv: provides the String object version of the tibrv advisory message

+     * Wombat Middleware

+     */

+    public void onTopicUnsubscribe(String topic, final Object platformInfo)

+    {

+        return;

+    }

+

+    /*  Original callbacks for backward compatibility  */

+    /**

+     * Invoked when a topic is subscribed to

+     *

      * @param cause The cause of the topic subscription

      * @param platformInfo Info associated with the topic subscription

      *

--

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.

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 Intercontinental Exchange, Inc. (ICE), 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.