Re: [PATCH] [mamda] map a delete msg through mamda as an error callback


Mike Schonberg <mschonberg@...>
 

Thanks Ian.

-Mike

-----Original Message-----
From: Ian Bell
Sent: Monday, May 21, 2012 11:39 PM
To: Mike Schonberg; openmama-dev@...
Subject: RE: [Openmama-dev] [PATCH] [mamda] map a delete msg through
mamda as an error callback



-----Original Message-----
From: Mike Schonberg
Sent: 21 May 2012 21:48
To: Ian Bell; openmama-dev@...
Subject: RE: [Openmama-dev] [PATCH] [mamda] map a delete msg through
mamda as an error callback



-----Original Message-----
From: openmama-dev-bounces@... [mailto:openmama-
dev-
bounces@...] On Behalf Of Ian Bell
Sent: Friday, May 18, 2012 8:58 AM
To: openmama-dev@...
Subject: [Openmama-dev] [PATCH] [mamda] map a delete msg through
mamda
as an error callback

commit be5ec93af947d5ed9458bf8a5e05b7300a9322d6

Author: Ian Bell <IBell@...>

Date: Thu May 17 21:47:41 2012 +0100



[mamda] map a delete msg through mamda as an error callback
We need a little more information here. What is a "delete" message?
When/why does it get sent? Why is it an error? This comment will ultimately
go into the release notes.

Regards,
-Mike

When using a MamdaSubscription and a msg of type delete is received
Mamda handles this internally and did not notify the user that this had
happened. As no more messages were received after the delete msg this
symbol effectively stopped ticking. This patch fires a callback on the
MamdaErrorListener to inform the user of the delete msg so they can take
any action they wish based on this information. (eg delete the subscription.)

I will try to be more verbose on any less straight forward patches in future.

Ian


Signed-off-by: Ian Bell <IBell@...>



diff --git a/mama/c_cpp/src/c/mama/status.h
b/mama/c_cpp/src/c/mama/status.h

index 1c48c00..ab51f63 100644

--- a/mama/c_cpp/src/c/mama/status.h

+++ b/mama/c_cpp/src/c/mama/status.h

@@ -94,6 +94,8 @@ typedef enum

MAMA_STATUS_INVALID_QUEUE = 27,

/* Not modifiable */

MAMA_STATUS_NOT_MODIFIABLE = 28,

+ /* Message Type DELETE */

+ MAMA_STATUS_DELETE = 29,

/* Not permissioned for the subject */

MAMA_STATUS_NOT_PERMISSIONED =
4001,

/* Subscription is in an invalid state. */

diff --git a/mama/c_cpp/src/c/status.c b/mama/c_cpp/src/c/status.c

index e8c1c31..f5cb3ff 100644

--- a/mama/c_cpp/src/c/status.c

+++ b/mama/c_cpp/src/c/status.c

@@ -57,6 +57,7 @@ mamaStatus_stringForStatus (mama_status status)

case MAMA_STATUS_NOT_INSTALLED : return "NOT_INSTALLED";

case MAMA_STATUS_NO_BRIDGE_IMPL : return "NO_BRIDGE_IMPL";

case MAMA_STATUS_INVALID_QUEUE : return "INVALID_QUEUE";

+ case MAMA_STATUS_DELETE : return "STATUS_DELETE";

case MAMA_STATUS_NOT_MODIFIABLE : return "NOT_MODIFIABLE";

case MAMA_STATUS_NOT_PERMISSIONED : return
"MAMA_STATUS_NOT_PERMISSIONED";

case MAMA_STATUS_SUBSCRIPTION_INVALID_STATE: return
"MAMA_STATUS_SUBSCRIPTION_INVALID_STATE";

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

index 52060d9..65da8d9 100644

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

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

@@ -81,6 +81,10 @@ public class MamaMsgStatus

/** Message with duplicate sequence number */

public static final short STATUS_DUPLICATE = 15;

+ /** Message with the type of DELETE */

+ public static final short STATUS_DELETE = 17;

+

+

public static final short STATUS_EXCEPTION = 999;

/**

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

index 9b6599c..d9a9d30 100644

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

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

@@ -471,6 +471,21 @@ namespace Wombat

switch (msgType)

{

case MAMA_MSG_TYPE_DELETE:

+ if (subscription->checkDebugLevel
+ (MAMA_LOG_LEVEL_FINE))

+ {

+ const char *contentSymbol = "N/A";

+ msg.tryString (MamdaCommonFields::ISSUE_SYMBOL,
contentSymbol);

+

+ mama_forceLog (MAMA_LOG_LEVEL_FINE,

+ "MamdaSubscription (%s.%s(%s)) "

+ "ignoring msg. type: %s\n",

+ mSource->getPublisherSourceName(),

+ mSymbol.c_str (),

+ contentSymbol,

+ msg.getMsgTypeName());

+ }

+ onError (subscription,
+ MAMA_STATUS_DELETE , "Msg
Type Delete");

+ return;

case MAMA_MSG_TYPE_EXPIRE:

if (subscription->checkDebugLevel
(MAMA_LOG_LEVEL_FINE))

{

@@ -566,6 +581,11 @@ namespace Wombat

code = MAMDA_ERROR_BAD_SYMBOL;

errStr = "bad symbol";

break;

+ case MAMA_STATUS_DELETE:

+ severity = MAMDA_SEVERITY_OK;

+ code = MAMDA_ERROR_DELETE;

+ errStr = "message type delete";

+ break;

case MAMA_STATUS_TIMEOUT:

severity = MAMDA_SEVERITY_HIGH;

code = MAMDA_ERROR_TIME_OUT;

diff --git a/mamda/c_cpp/src/cpp/mamda/MamdaErrorListener.h
b/mamda/c_cpp/src/cpp/mamda/MamdaErrorListener.h

index d93877f..5168987 100644

--- a/mamda/c_cpp/src/cpp/mamda/MamdaErrorListener.h

+++ b/mamda/c_cpp/src/cpp/mamda/MamdaErrorListener.h

@@ -57,7 +57,7 @@ namespace Wombat

MAMDA_ERROR_TIME_OUT,

MAMDA_ERROR_ENTITLEMENT,

MAMDA_ERROR_NOT_FOUND,

- MAMDA_ERROR_WATCH_THIS_SPACE

+ MAMDA_ERROR_DELETE

};

/**

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

index fa25213..59de128 100644

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

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

@@ -72,6 +72,9 @@ public class MamdaErrorCode

/** Bandwidth exceeded */

public static final short MAMDA_ERROR_BANDWIDTH_EXCEEDED = 14;

+ /** Message of type DELETE */

+ public static final short MAMDA_ERROR_DELETE = 17;

+

public static final short MAMDA_ERROR_EXCEPTION = 999;



@@ -100,6 +103,7 @@ public class MamdaErrorCode

case MAMDA_ERROR_TOPIC_CHANGE: return "TOPIC_CHANGE";

case MAMDA_ERROR_BANDWIDTH_EXCEEDED: return
"BANDWIDTH_EXCEEDED";

case MAMDA_ERROR_EXCEPTION: return "EXCEPTION
PROCESSING
MESSAGE";

+ case MAMDA_ERROR_DELETE: return "MESSAGE TYPE DELETE";

default: return "UNKNOWN";

}

}

@@ -124,6 +128,7 @@ public class MamdaErrorCode

case MamaMsgStatus.STATUS_TOPIC_CHANGE: return
MAMDA_ERROR_TOPIC_CHANGE;

case MamaMsgStatus.STATUS_BANDWIDTH_EXCEEDED: return
MAMDA_ERROR_BANDWIDTH_EXCEEDED;

case MamaMsgStatus.STATUS_EXCEPTION: return
MAMDA_ERROR_EXCEPTION;

+ case MamaMsgStatus.STATUS_DELETE: return
MAMDA_ERROR_DELETE;

}

return -1;

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

index 3d82225..46efd13 100644

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

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

@@ -470,10 +470,15 @@ public class MamdaSubscription

short msgType = MamaMsgType.typeForMsg (msg);

int msgStatus = MamaMsgStatus.statusForMsg (msg);

mLatestMsg = msg;

+ short mywombatStatus = 17;

+ int myplatformError = 0;

+ Exception myException = new Exception();

switch (msgType)

{

case MamaMsgType.TYPE_DELETE:

+ onError (subscription, mywombatStatus,
+ myplatformError,
"Message Type Delete", myException);

+ return;

case MamaMsgType.TYPE_EXPIRE:

subscription.destroy();

mLatestMsg = null;


________________________________

Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient or have received this e-mail in
error, please advise the sender immediately by reply e-mail and delete
this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com

****************************************************

Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.