Exemplo n.º 1
0
static void initializeMama ()
{
    mama_status status;

    status = mama_loadBridge (&gPubBridge, gPubMiddleware);
    status = mama_loadBridge (&gSubBridge, gSubMiddleware);

    mama_open();

    mama_getDefaultEventQueue (gPubBridge, &gPubDefaultQueue);
    mama_getDefaultEventQueue (gSubBridge, &gSubDefaultQueue);

    mamaTransport_allocate (&gSubTransport);
    mamaTransport_create (gSubTransport,
                          gSubTransportName,
                          gSubBridge);

    mamaTransport_allocate (&gPubTransport);
    mamaTransport_create (gPubTransport,
                          gPubTransportName,
                          gPubBridge);

    /*The mamaSource used for all subscription creation*/
    if (MAMA_STATUS_OK!=(status=mamaSource_create (&gSubscriptionSource)))
    {
        fprintf (stderr,
                 "Failed to create subscription mamaSource STATUS: %d %s\n",
                 status, mamaStatus_stringForStatus (status));
        exit(1);
    }

    mamaSource_setId (gSubscriptionSource, "Subscription_Source");
    mamaSource_setTransport (gSubscriptionSource, gSubTransport);
    mamaSource_setSymbolNamespace (gSubscriptionSource, gSubSource);


}
Exemplo n.º 2
0
 void MamaSource::setId (const char*  id)
 {
     mamaTry (mamaSource_setId (mySource, id));
 }
Exemplo n.º 3
0
mama_status
mamaCaptureList_parseCommandInput (mamaCaptureConfig subCapture,
                                   mamaCaptureList captureList,
                                   char* commandArg)
{
    mamaCaptureSourceList* sourceList =
        (mamaCaptureSourceList*)captureList;
    mamaCapture * capture = (mamaCapture*)subCapture;

    char* source        = NULL;
    char* transportName = NULL;
    char* symbolFile    = NULL;
    int   transportCreated  = 0;

    FILE* fp = NULL;
    char charbuf[1024];

    if (capture == NULL) return MAMA_STATUS_NULL_ARG;

    if (sourceList == NULL)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,
                  "parseCommandInput : NullPointer " \
                  "Exception ");
        return MAMA_STATUS_NULL_ARG;
    }

    source        = strtok (commandArg, ":");
    transportName = strtok (NULL, ":");
    symbolFile    = strtok (NULL, " ");

    if (symbolFile != NULL)
    {
        if ((fp = fopen (symbolFile, "r")) == (FILE *)NULL)
        {
            perror (symbolFile);
            exit (1);
        }
    }

    while (fgets (charbuf, 1023, fp))
    {
        char *c = charbuf;
        while ((*c != '\0') && (*c != '\n'))
            c++;
        *c = '\0';
        sourceList[gCounter].mySymbolNamespace = strdup (source);
        sourceList[gCounter].myTransportName   = strdup (transportName);
        sourceList[gCounter].mySymbol          = strdup (charbuf);

        mamaSource_create (&sourceList[gCounter].mySource);
        mamaSource_setId (sourceList[gCounter].mySource,
                          sourceList[gCounter].mySymbolNamespace);
        mamaSource_setSymbolNamespace (sourceList[gCounter].mySource,
                                       sourceList[gCounter].mySymbolNamespace);
        if (transportCreated == 0)
        {
            createTransport(capture,&sourceList[gCounter].myTransport,
                            sourceList[gCounter].myTransportName);
            transportCreated = 1;
        }
        else
        {
            sourceList[gCounter].myTransport=
                sourceList[gCounter-1].myTransport;
        }
        mamaSource_setTransport (sourceList[gCounter].mySource,
                                 sourceList[gCounter].myTransport);
        gCounter++;
    }
    fclose (fp);
    fp = NULL;

    return MAMA_STATUS_OK;
}