mama_status dqContext_cacheMsg (mamaDqContext *ctx, mamaMsg msg) { mama_status status = MAMA_STATUS_OK; if (ctx->mCache == NULL) { return status; } if (ctx->mCache[ctx->mCurCacheIdx] != NULL) { mamaMsg_destroy (ctx->mCache[ctx->mCurCacheIdx]); } mamaMsg_detach (msg); ctx->mCache [ctx->mCurCacheIdx++] = msg; if (ctx->mCurCacheIdx == ctx->mCacheSize) { ctx->mCurCacheIdx = 0; } /*Associate the cache context with the message. This must be done after it has been detached*/ if (MAMA_STATUS_OK!=(status=mamaMsgImpl_setDqStrategyContext (msg, ctx))) { mama_log (MAMA_LOG_LEVEL_ERROR, "dqContext_cacheMsg: " "Could not set context on detached message."); return status; } return status; }
static void MAMACALLTYPE subscriptionHandlerOnNewRequestCb (mamaDQPublisherManager manager, const char* symbol, short subType, short msgType, mamaMsg msg) { int i = 0; mamaQueue queue; recapInfo* info = NULL; for (i=0; i < gNumSymbols; i++) { if (strcmp (gSubscriptionList[i].symbol, symbol) == 0) break; } if (i == gNumSymbols) { printf ("Received request for unknown symbol: %s\n", symbol); return; } mamaDQPublisherManager_createPublisher (manager, symbol, (void*)i, &gSubscriptionList[i].pub); printf ("Received new request: %s\n", symbol); info = (recapInfo*) calloc (1, sizeof(recapInfo)); info->index =i; mamaSubscription_getQueue(gSubscriptionList[i].sub, &queue); switch (msgType) { case MAMA_SUBSC_SUBSCRIBE: case MAMA_SUBSC_SNAPSHOT: mamaMsg_detach (msg); info->msg = msg; mamaQueue_enqueueEvent (queue, sendRecap, info); break; default: mamaQueue_enqueueEvent (queue, sendRecap, info); break; } }
static void MAMACALLTYPE subscriptionHandlerOnRequestCb (mamaDQPublisherManager manager, mamaPublishTopic* publishTopicInfo, short subType, short msgType, mamaMsg msg) { recapInfo* info = NULL; pubCache* cache = NULL; mamaQueue queue; printf ("Received request: %s\n", publishTopicInfo->symbol); switch (msgType) { case MAMA_SUBSC_SUBSCRIBE: case MAMA_SUBSC_SNAPSHOT: mamaMsg_detach (msg); info = (recapInfo*) calloc (1, sizeof(recapInfo)); cache = publishTopicInfo->cache; info->index = cache->index; info->msg = msg; mamaSubscription_getQueue(cache->sub, &queue); mamaQueue_enqueueEvent (queue, sendRecap, info); break; case MAMA_SUBSC_DQ_SUBSCRIBER : case MAMA_SUBSC_DQ_PUBLISHER: case MAMA_SUBSC_DQ_NETWORK: case MAMA_SUBSC_DQ_UNKNOWN: case MAMA_SUBSC_DQ_GROUP_SUBSCRIBER: info = (recapInfo*) calloc (1, sizeof(recapInfo)); cache = publishTopicInfo->cache; info->index = cache->index; mamaSubscription_getQueue(cache->sub, &queue); mamaQueue_enqueueEvent (queue, sendRecap, info); break; case MAMA_SUBSC_UNSUBSCRIBE: case MAMA_SUBSC_RESUBSCRIBE: case MAMA_SUBSC_REFRESH: default: break; } }
mama_status mamaConflationManager_enqueue (mamaConflationManager mgr, mamaMsg msg, const char* topic) { mamaConflationMgr* impl = (mamaConflationMgr*)mgr; mama_status status = MAMA_STATUS_OK; if (impl == NULL) return MAMA_STATUS_INVALID_ARG; if (!impl->mInstalled) return MAMA_STATUS_NOT_INSTALLED; /* * We need to detach the message to put it on the queue, and make sure * that the underlying buffer does not get freed. * * TODO: We may want to simply enqueue the buffer and wrap in a mamaMsg * when the caller examines it. The only tricky part is that we would have * to move some of the logic into the bridge since it knows how to convert * buffers into messages (trickier than you might think). * * We do this here rather than in processData so the C++ wrapper works. */ if (msg == impl->mMsg) { status = mamaMsg_create (&impl->mMsg); mamaMsg_detach (msg); } if (status == MAMA_STATUS_OK && wombatQueue_enqueue (impl->mMsgQueue, NULL, msg, (void*)topic) != WOMBAT_QUEUE_OK) { return MAMA_STATUS_NOMEM; } return status; }