activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1068094 - in /activemq/activemq-cpp/trunk/activemq-c/src/examples: Makefile.am consumers/ consumers/SimpleConsumer.c producers/ producers/SimpleProducer.c
Date Mon, 07 Feb 2011 20:12:46 GMT
Author: tabish
Date: Mon Feb  7 20:12:46 2011
New Revision: 1068094

URL: http://svn.apache.org/viewvc?rev=1068094&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQCPP-321

Added:
    activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/
    activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/SimpleConsumer.c   (with
props)
    activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/
    activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/SimpleProducer.c   (with
props)
Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/examples/Makefile.am

Modified: activemq/activemq-cpp/trunk/activemq-c/src/examples/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/examples/Makefile.am?rev=1068094&r1=1068093&r2=1068094&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/examples/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/examples/Makefile.am Mon Feb  7 20:12:46 2011
@@ -26,3 +26,17 @@ bin_PROGRAMS = example 
 example_SOURCES = $(main_example_sources)
 example_LDADD= $(AMQ_TEST_LIBS)
 example_CFLAGS = $(AMQ_TEST_CFLAGS) -I$(srcdir)/../main/c
+
+## Simple Consumer
+simple_consumer_sources = ./consumers/SimpleConsumer.c
+noinst_PROGRAMS = simple_consumer 
+simple_consumer_SOURCES = $(simple_consumer_sources)
+simple_consumer_LDADD= $(AMQ_TEST_LIBS)
+simple_consumer_CFLAGS = $(AMQ_TEST_CFLAGS) -I$(srcdir)/../main/c
+
+## Simple Producer
+simple_producer_sources = ./producers/SimpleProducer.c
+noinst_PROGRAMS += simple_producer 
+simple_producer_SOURCES = $(simple_producer_sources)
+simple_producer_LDADD= $(AMQ_TEST_LIBS)
+simple_producer_CFLAGS = $(AMQ_TEST_CFLAGS) -I$(srcdir)/../main/c
\ No newline at end of file

Added: activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/SimpleConsumer.c
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/SimpleConsumer.c?rev=1068094&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/SimpleConsumer.c (added)
+++ activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/SimpleConsumer.c Mon Feb
 7 20:12:46 2011
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cms.h>
+#include <CMS_ConnectionFactory.h>
+#include <CMS_Connection.h>
+#include <CMS_Session.h>
+#include <CMS_Message.h>
+#include <CMS_MessageConsumer.h>
+#include <CMS_MessageProducer.h>
+#include <CMS_Destination.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char* argv[]) {
+
+    cms_initialize();
+
+    printf("=====================================================\n");
+    printf("Starting the SimpleConsumer:\n");
+    printf("-----------------------------------------------------\n");
+
+    const char* brokerUri = "failover:(tcp://127.0.0.1:61616)";
+    const char* queueName = "cms.test.c.client.queue";
+
+    CMS_ConnectionFactory* factory = NULL;
+    CMS_Connection* connection = NULL;
+    CMS_Session* session = NULL;
+    CMS_Destination* destination = NULL;
+    CMS_MessageConsumer* consumer = NULL;
+    CMS_Message* txtMessage = NULL;
+
+    if (createConnectionFactory(&factory, brokerUri, NULL, NULL) != CMS_SUCCESS) {
+        printf("Failed to create a Connection Factory\n");
+        exit(1);
+    }
+
+    if (createDefaultConnection(factory, &connection) != CMS_SUCCESS) {
+        printf("Failed to create a Connection\n");
+        exit(1);
+    }
+
+    destroyConnectionFactory(factory);
+
+    if (createDefaultSession(connection, &session) != CMS_SUCCESS) {
+        printf("Failed to create a Session\n");
+        exit(1);
+    }
+
+    if (createDestination(session, CMS_QUEUE, queueName, &destination) != CMS_SUCCESS)
{
+        printf("Failed to create a Destination\n");
+        exit(1);
+    }
+
+    if (createDefaultConsumer(session, destination, &consumer) != CMS_SUCCESS) {
+        printf("Failed to create a MessageConsumer\n");
+        exit(1);
+    }
+
+    if (startConnection(connection) != CMS_SUCCESS) {
+        printf("Failed to start the Connection\n");
+        exit(1);
+    }
+
+    int i;
+    for(i = 0; i < 10; ++i) {
+        CMS_Message* message = NULL;
+        if (consumerReceiveWithTimeout(consumer, &message, 5000) != CMS_SUCCESS) {
+            printf("Timed Receive call terminated abnormally\n");
+            exit(1);
+        }
+
+        printf("Received Message #%d\n", i);
+        destroyMessage(message);
+    }
+
+    destroyConsumer(consumer);
+    destroyDestination(destination);
+    destroySession(session);
+    destroyConnection(connection);
+
+    printf("-----------------------------------------------------\n");
+    printf("Finished with the SimpleConsumer.\n");
+    printf("=====================================================\n");
+
+    cms_terminate();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-c/src/examples/consumers/SimpleConsumer.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/SimpleProducer.c
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/SimpleProducer.c?rev=1068094&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/SimpleProducer.c (added)
+++ activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/SimpleProducer.c Mon Feb
 7 20:12:46 2011
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cms.h>
+#include <CMS_ConnectionFactory.h>
+#include <CMS_Connection.h>
+#include <CMS_Session.h>
+#include <CMS_Message.h>
+#include <CMS_MessageProducer.h>
+#include <CMS_Destination.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char* argv[]) {
+
+    cms_initialize();
+
+    printf("=====================================================\n");
+    printf("Starting the SimpleProducer:\n");
+    printf("-----------------------------------------------------\n");
+
+    const char* brokerUri = "failover:(tcp://127.0.0.1:61616)";
+    const char* queueName = "cms.test.c.client.queue";
+
+    CMS_ConnectionFactory* factory = NULL;
+    CMS_Connection* connection = NULL;
+    CMS_Session* session = NULL;
+    CMS_Destination* destination = NULL;
+    CMS_MessageProducer* producer = NULL;
+    CMS_Message* txtMessage = NULL;
+
+    if (createConnectionFactory(&factory, brokerUri, NULL, NULL) != CMS_SUCCESS) {
+        printf("Failed to create a Connection Factory\n");
+        exit(1);
+    }
+
+    if (createDefaultConnection(factory, &connection) != CMS_SUCCESS) {
+        printf("Failed to create a Connection\n");
+        exit(1);
+    }
+
+    destroyConnectionFactory(factory);
+
+    if (createDefaultSession(connection, &session) != CMS_SUCCESS) {
+        printf("Failed to create a Session\n");
+        exit(1);
+    }
+
+    if (createDestination(session, CMS_QUEUE, queueName, &destination) != CMS_SUCCESS)
{
+        printf("Failed to create a Destination\n");
+        exit(1);
+    }
+
+    if (createProducer(session, destination, &producer) != CMS_SUCCESS) {
+        printf("Failed to create a MessageProducer\n");
+        exit(1);
+    }
+
+    int i = 0;
+    for(; i < 10; ++i) {
+        CMS_Message* message = NULL;
+        createTextMessage(session, &message, "Test Message");
+
+        if (producerSendWithDefaults(producer, message) != CMS_SUCCESS) {
+            printf("Failed to send the Message\n");
+            destroyMessage(message);
+            exit(1);
+        }
+
+        destroyMessage(message);
+    }
+
+    if (startConnection(connection) != CMS_SUCCESS) {
+        printf("Failed to start the Connection\n");
+        exit(1);
+    }
+
+    destroyProducer(producer);
+    destroyDestination(destination);
+    destroySession(session);
+    destroyConnection(connection);
+
+    printf("-----------------------------------------------------\n");
+    printf("Finished with the SimpleProducer.\n");
+    printf("=====================================================\n");
+
+    cms_terminate();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-c/src/examples/producers/SimpleProducer.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message