void RMDSBridgeSubscription::SendStatusMessage( mamaMsgStatus secStatus ) { if (isShutdown_) { // just don't bother making the callback return; } // create and send a message containing the (failed) status mamaMsg msg; mamaMsg_createForPayload(&msg, MAMA_PAYLOAD_TICK42RMDS); mamaMsg_addI32(msg, MamaFieldMsgType.mName, MamaFieldMsgType.mFid, MAMA_MSG_TYPE_SEC_STATUS); mamaMsg_addI32(msg, MamaFieldMsgStatus.mName, MamaFieldMsgStatus.mFid, secStatus); const CommonFields &commonFields = UpaMamaCommonFields::CommonFields(); mamaMsg_addString(msg, commonFields.wIssueSymbol.mama_field_name.c_str(),commonFields.wIssueSymbol.mama_fid, symbol_.c_str()); mamaMsg_addString(msg, commonFields.wSymbol.mama_field_name.c_str(), commonFields.wSymbol.mama_fid, symbol_.c_str()); mama_status status = MAMA_STATUS_OK; try { status = mamaSubscription_processMsg(subscription_, msg); } catch (...) { mamaMsg_destroy(msg); t42log_error("RMDSBridgeSubscription::OnMessage - caught exception calling mamaSubscription_processMsg for %s", symbol_.c_str()); } if (MAMA_STATUS_OK != status) { mama_log (MAMA_LOG_LEVEL_ERROR, "RMDSBridgeSubscription::OnMessage: " "mamaSubscription_processMsg() failed. [%d]", status); } mamaMsg_destroy(msg); }
UPAConsumer::UPAConsumer(RMDSSubscriber * pOwner) : shouldRecoverConnection_(RSSL_TRUE) , rsslConsumerChannel_(NULL) , receivedServerMsg_ (RSSL_FALSE) , connectionConfig_(pOwner->Config()->getString("hosts"), pOwner->Config()->getString("retrysched", Default_retrysched)) ,requiresConnection_(true) { isInLoginSuspectState_ = RSSL_FALSE; owner_ = pOwner; if (pOwner->InterfaceName()) { interfaceName_ = ::strdup(pOwner->InterfaceName()); } else { interfaceName_ = NULL; } // if no hosts list dont try and connect // this lets us run a subscriber that is not connected - allows mama to subscribe for special topis such as new item request that are created by the publisher // then marshalled into a subscriber if (connectionConfig_.NumHosts() == 0) { t42log_warn("No hosts specified for transport %s - WILL NOT ATTEMPT CONNECTION\n", pOwner->GetTransportName().c_str()); shouldRecoverConnection_ = RSSL_FALSE; requiresConnection_ = false; } connType_ = pOwner->ConnType(); requestQueue_ = pOwner->GetRequestQueue(); TransportConfig_t config(pOwner->GetTransportName()); login_ = new UPALogin(false); login_->ConfigureEntitlements(&config); // Use the DACS settings in the configuration to login // config for throttle maxDispatchesPerCycle_ = config.getInt("maxdisp", Default_maxdisp); maxPendingOpens_ = config.getInt("maxPending", Default_maxPending); t42log_info("Consumer thread request throttle parameters - max dispatches = %d max pending = %d\n", maxDispatchesPerCycle_, maxPendingOpens_); bool configDisableDataConversion = config.getBool("disabledataconversion",false); // initialise the source directory and dictionary management components login_->AddListener(pOwner); login_->DisableDataConversion(configDisableDataConversion); sourceDirectory_ = new UPASourceDirectory(); sourceDirectory_->AddListener(pOwner); upaDictionary_ = boost::make_shared<UPADictionary>(pOwner->GetTransportName()); upaDictionary_->AddListener(pOwner); // init statistics incomingMessageCount_ = 0; lastMessageCount_ = 0; lastSampleTime_ = utils::time::GetMilliCount(); totalSubscriptions_ = totalSubscriptionsSucceeded_ = totalSubscriptionsFailed_ = 0; // create the shared mama message mamaMsg_createForPayload(&msg_, MAMA_PAYLOAD_TICK42RMDS); runThread_ = true; }
int main (int argc, const char **argv) { mamaPlaybackFileParser fileParser = NULL; mamaPlaybackCapture fileCapture = NULL; char* headerString = NULL; mamaMsg sourceMsg = NULL; mamaMsg targetMsg = NULL; mamaMsgField aField = NULL; mamaBridge gMamaBridge = NULL; mamaMsgIterator iterator = NULL; mamaFieldType fieldType = MAMA_FIELD_TYPE_UNKNOWN; parseCommandLine (argc, argv); mama_loadBridge (&gMamaBridge, "wmw"); mama_loadBridge (&gMamaBridge, "avis"); mama_open (); mamaPlaybackFileParser_allocate (&fileParser); mamaPlaybackFileParser_openFile(fileParser, (char*)gInputFilename); mamaCapture_allocate(&fileCapture); mamaCapture_openFile (&fileCapture, gOutputFilename); mamaMsgIterator_create(&iterator, NULL); mamaMsg_createForPayload(&targetMsg, 'A'); while (mamaPlaybackFileParser_getNextHeader(fileParser, &headerString)) { if (mamaPlaybackFileParser_getNextMsg (fileParser, &sourceMsg)) { char temp[64]; char* start = headerString; char* end = strchr (headerString,':'); strncpy (temp,start, end-start); temp[end-start]='\0'; mamaCapture_setFeedSource (&fileCapture, temp); end++; start=end; end = strchr (start,':'); strncpy (temp,start, end-start);temp[end-start]='\0'; mamaCapture_setTransportName (&fileCapture, temp); end++; start=end; end = strchr (start,'\0'); strncpy (temp,start, end-start);temp[end-start]='\0'; mamaCapture_setSymbol (&fileCapture, temp); mamaMsgIterator_associate(iterator, sourceMsg); mamaMsg_clear(targetMsg); while ((aField = mamaMsgIterator_next(iterator)) != NULL) { uint16_t fid = 0; mamaMsgField_getFid(aField, &fid); mamaMsgField_getType(aField, &fieldType); switch (fieldType) { case MAMA_FIELD_TYPE_BOOL: { mama_bool_t result; mamaMsgField_getBool (aField, &result); mamaMsg_addBool(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_CHAR: {char result; mamaMsgField_getChar (aField, &result); mamaMsg_addChar(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I8: {mama_i8_t result; mamaMsgField_getI8 (aField, &result); mamaMsg_addI8(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U8: {mama_u8_t result; mamaMsgField_getU8 (aField, &result); mamaMsg_addU8(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I16: {mama_i16_t result; mamaMsgField_getI16 (aField, &result); mamaMsg_addI16(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U16: {mama_u16_t result; mamaMsgField_getU16 (aField, &result); mamaMsg_addU16(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I32: {mama_i32_t result; mamaMsgField_getI32 (aField, &result); mamaMsg_addI32(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U32: {mama_u32_t result; mamaMsgField_getU32 (aField, &result); mamaMsg_addU32(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I64: {mama_i64_t result; mamaMsgField_getI64 (aField, &result); mamaMsg_addI64(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U64: {mama_u64_t result; mamaMsgField_getU64 (aField, &result); mamaMsg_addU64(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_F32: {mama_f32_t result; mamaMsgField_getF32 (aField, &result); mamaMsg_addF32(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_F64: {mama_f64_t result; mamaMsgField_getF64 (aField, &result); mamaMsg_addF64(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_STRING: {const char* result; mamaMsgField_getString (aField, &result); mamaMsg_addString(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_TIME: { mamaDateTime result; mamaMsgField_getDateTime (aField, result); mamaMsg_addDateTime(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_PRICE: { mamaPrice result; mamaMsgField_getPrice(aField, result); mamaMsg_addPrice(targetMsg, NULL, fid, result); }break; default: case MAMA_FIELD_TYPE_VECTOR_I8: case MAMA_FIELD_TYPE_VECTOR_U8: case MAMA_FIELD_TYPE_VECTOR_I16: case MAMA_FIELD_TYPE_VECTOR_U16: case MAMA_FIELD_TYPE_VECTOR_I32: case MAMA_FIELD_TYPE_VECTOR_U32: case MAMA_FIELD_TYPE_VECTOR_I64: case MAMA_FIELD_TYPE_VECTOR_U64: case MAMA_FIELD_TYPE_VECTOR_F32: case MAMA_FIELD_TYPE_VECTOR_F64: case MAMA_FIELD_TYPE_VECTOR_STRING: case MAMA_FIELD_TYPE_VECTOR_MSG: case MAMA_FIELD_TYPE_VECTOR_TIME: case MAMA_FIELD_TYPE_VECTOR_PRICE: case MAMA_FIELD_TYPE_QUANTITY: case MAMA_FIELD_TYPE_COLLECTION : case MAMA_FIELD_TYPE_UNKNOWN: case MAMA_FIELD_TYPE_OPAQUE: case MAMA_FIELD_TYPE_MSG: break; } } mamaCapture_saveMamaMsg (&fileCapture, &targetMsg); } } mamaMsgIterator_destroy(iterator); mamaCapture_closeFile(fileCapture); mamaCapture_deallocate (fileCapture); mamaPlaybackFileParser_closeFile(fileParser); mamaPlaybackFileParser_deallocate (fileParser); return (0); }