diff options
author | Gordon Sim <gsim@apache.org> | 2009-08-25 17:57:34 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2009-08-25 17:57:34 +0000 |
commit | 082fa377137d1a73382a0c3f1ab22b5abe6cb485 (patch) | |
tree | 27375051e0f05a91ff63f123b2b027916840221c /cpp/examples/messaging | |
parent | 28e1de98b115ebc834a1e232bfd630809689a59e (diff) | |
download | qpid-python-082fa377137d1a73382a0c3f1ab22b5abe6cb485.tar.gz |
QPID-664: Initial checkin of high level messaging api for c++
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@807731 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/examples/messaging')
-rw-r--r-- | cpp/examples/messaging/CMakeLists.txt | 32 | ||||
-rw-r--r-- | cpp/examples/messaging/Makefile.am | 54 | ||||
-rw-r--r-- | cpp/examples/messaging/Makefile.in | 657 | ||||
-rw-r--r-- | cpp/examples/messaging/client.cpp | 76 | ||||
-rw-r--r-- | cpp/examples/messaging/map_receiver.cpp | 54 | ||||
-rw-r--r-- | cpp/examples/messaging/map_sender.cpp | 66 | ||||
-rw-r--r-- | cpp/examples/messaging/queue_listener.cpp | 82 | ||||
-rw-r--r-- | cpp/examples/messaging/queue_receiver.cpp | 65 | ||||
-rw-r--r-- | cpp/examples/messaging/queue_sender.cpp | 65 | ||||
-rw-r--r-- | cpp/examples/messaging/server.cpp | 78 | ||||
-rw-r--r-- | cpp/examples/messaging/topic_listener.cpp | 82 | ||||
-rw-r--r-- | cpp/examples/messaging/topic_receiver.cpp | 66 | ||||
-rw-r--r-- | cpp/examples/messaging/topic_sender.cpp | 78 |
13 files changed, 1455 insertions, 0 deletions
diff --git a/cpp/examples/messaging/CMakeLists.txt b/cpp/examples/messaging/CMakeLists.txt new file mode 100644 index 0000000000..e7885d0b50 --- /dev/null +++ b/cpp/examples/messaging/CMakeLists.txt @@ -0,0 +1,32 @@ +# +# 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. +# + +add_example(messaging queue_listener) +add_example(messaging queue_receiver) +add_example(messaging queue_sender) + +add_example(messaging topic_listener) +add_example(messaging topic_receiver) +add_example(messaging topic_sender) + +add_example(messaging map_receiver) +add_example(messaging map_sender) + +add_example(messaging client) +add_example(messaging server) diff --git a/cpp/examples/messaging/Makefile.am b/cpp/examples/messaging/Makefile.am new file mode 100644 index 0000000000..250e549e82 --- /dev/null +++ b/cpp/examples/messaging/Makefile.am @@ -0,0 +1,54 @@ +# +# 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. +# +examplesdir=$(pkgdatadir)/examples/messaging + +MAKELDFLAGS=$(CLIENTFLAGS) +include $(top_srcdir)/examples/makedist.mk + +noinst_PROGRAMS=queue_sender queue_listener queue_receiver topic_sender topic_listener topic_receiver client server map_sender map_receiver + +queue_sender_SOURCES=queue_sender.cpp +queue_sender_LDADD=$(CLIENT_LIB) + +queue_listener_SOURCES=queue_listener.cpp +queue_listener_LDADD=$(CLIENT_LIB) + +queue_receiver_SOURCES=queue_receiver.cpp +queue_receiver_LDADD=$(CLIENT_LIB) + +topic_sender_SOURCES=topic_sender.cpp +topic_sender_LDADD=$(CLIENT_LIB) + +topic_listener_SOURCES=topic_listener.cpp +topic_listener_LDADD=$(CLIENT_LIB) + +topic_receiver_SOURCES=topic_receiver.cpp +topic_receiver_LDADD=$(CLIENT_LIB) + +client_SOURCES=client.cpp +client_LDADD=$(CLIENT_LIB) + +server_SOURCES=server.cpp +server_LDADD=$(CLIENT_LIB) + +map_sender_SOURCES=map_sender.cpp +map_sender_LDADD=$(CLIENT_LIB) + +map_receiver_SOURCES=map_receiver.cpp +map_receiver_LDADD=$(CLIENT_LIB) diff --git a/cpp/examples/messaging/Makefile.in b/cpp/examples/messaging/Makefile.in new file mode 100644 index 0000000000..9a7b236068 --- /dev/null +++ b/cpp/examples/messaging/Makefile.in @@ -0,0 +1,657 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/examples/makedist.mk +noinst_PROGRAMS = queue_sender$(EXEEXT) queue_listener$(EXEEXT) \ + queue_receiver$(EXEEXT) topic_sender$(EXEEXT) \ + topic_listener$(EXEEXT) topic_receiver$(EXEEXT) \ + client$(EXEEXT) server$(EXEEXT) map_sender$(EXEEXT) \ + map_receiver$(EXEEXT) +subdir = examples/messaging +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pkg_swig.m4 \ + $(top_srcdir)/m4/clock_time.m4 \ + $(top_srcdir)/m4/compiler-flags.m4 \ + $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_client_OBJECTS = client.$(OBJEXT) +client_OBJECTS = $(am_client_OBJECTS) +client_DEPENDENCIES = $(CLIENT_LIB) +am_map_receiver_OBJECTS = map_receiver.$(OBJEXT) +map_receiver_OBJECTS = $(am_map_receiver_OBJECTS) +map_receiver_DEPENDENCIES = $(CLIENT_LIB) +am_map_sender_OBJECTS = map_sender.$(OBJEXT) +map_sender_OBJECTS = $(am_map_sender_OBJECTS) +map_sender_DEPENDENCIES = $(CLIENT_LIB) +am_queue_listener_OBJECTS = queue_listener.$(OBJEXT) +queue_listener_OBJECTS = $(am_queue_listener_OBJECTS) +queue_listener_DEPENDENCIES = $(CLIENT_LIB) +am_queue_receiver_OBJECTS = queue_receiver.$(OBJEXT) +queue_receiver_OBJECTS = $(am_queue_receiver_OBJECTS) +queue_receiver_DEPENDENCIES = $(CLIENT_LIB) +am_queue_sender_OBJECTS = queue_sender.$(OBJEXT) +queue_sender_OBJECTS = $(am_queue_sender_OBJECTS) +queue_sender_DEPENDENCIES = $(CLIENT_LIB) +am_server_OBJECTS = server.$(OBJEXT) +server_OBJECTS = $(am_server_OBJECTS) +server_DEPENDENCIES = $(CLIENT_LIB) +am_topic_listener_OBJECTS = topic_listener.$(OBJEXT) +topic_listener_OBJECTS = $(am_topic_listener_OBJECTS) +topic_listener_DEPENDENCIES = $(CLIENT_LIB) +am_topic_receiver_OBJECTS = topic_receiver.$(OBJEXT) +topic_receiver_OBJECTS = $(am_topic_receiver_OBJECTS) +topic_receiver_DEPENDENCIES = $(CLIENT_LIB) +am_topic_sender_OBJECTS = topic_sender.$(OBJEXT) +topic_sender_OBJECTS = $(am_topic_sender_OBJECTS) +topic_sender_DEPENDENCIES = $(CLIENT_LIB) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(client_SOURCES) $(map_receiver_SOURCES) \ + $(map_sender_SOURCES) $(queue_listener_SOURCES) \ + $(queue_receiver_SOURCES) $(queue_sender_SOURCES) \ + $(server_SOURCES) $(topic_listener_SOURCES) \ + $(topic_receiver_SOURCES) $(topic_sender_SOURCES) +DIST_SOURCES = $(client_SOURCES) $(map_receiver_SOURCES) \ + $(map_sender_SOURCES) $(queue_listener_SOURCES) \ + $(queue_receiver_SOURCES) $(queue_sender_SOURCES) \ + $(server_SOURCES) $(topic_listener_SOURCES) \ + $(topic_receiver_SOURCES) $(topic_sender_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMQP_FINAL_XML = @AMQP_FINAL_XML@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILER_FLAGS = @COMPILER_FLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOWNLOAD_URL = @DOWNLOAD_URL@ +DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HELP2MAN = @HELP2MAN@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBTOOL_VERSION_INFO_ARG = @LIBTOOL_VERSION_INFO_ARG@ +LIB_ACL = @LIB_ACL@ +LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ +LIB_DLOPEN = @LIB_DLOPEN@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NSPR_CONFIG = @NSPR_CONFIG@ +NSS_CONFIG = @NSS_CONFIG@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_INC = @PYTHON_INC@ +PYTHON_LIB = @PYTHON_LIB@ +PYTHON_LIBS = @PYTHON_LIBS@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RPMLINT = @RPMLINT@ +RUBY = @RUBY@ +RUBY_DLEXT = @RUBY_DLEXT@ +RUBY_INC = @RUBY_INC@ +RUBY_INC_ARCH = @RUBY_INC_ARCH@ +RUBY_LIB = @RUBY_LIB@ +RUBY_LIBS = @RUBY_LIBS@ +RUBY_LIB_ARCH = @RUBY_LIB_ARCH@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKLIBS = @SOCKLIBS@ +SSL_CFLAGS = @SSL_CFLAGS@ +SSL_LDFLAGS = @SSL_LDFLAGS@ +STRIP = @STRIP@ +SUNCC_RUNTIME_LIBS = @SUNCC_RUNTIME_LIBS@ +SWIG = @SWIG@ +SWIG_LIB = @SWIG_LIB@ +URL = @URL@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WARNING_CFLAGS = @WARNING_CFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# +# 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. +# +examplesdir = $(pkgdatadir)/examples/messaging +MAKELDFLAGS = $(CLIENTFLAGS) + +# Settings to build the examples in automake +AM_CXXFLAGS = $(WARNING_CFLAGS) +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include +CLIENT_LIB = $(top_builddir)/src/libqpidclient.la +CONSOLE_LIB = $(top_builddir)/src/libqmfconsole.la +CLIENTFLAGS = -lqpidclient +CONSOLEFLAGS = -lqmfconsole + +# Generate a simple non-automake Makefile for distribution. +MAKEDIST = .libs/Makefile +queue_sender_SOURCES = queue_sender.cpp +queue_sender_LDADD = $(CLIENT_LIB) +queue_listener_SOURCES = queue_listener.cpp +queue_listener_LDADD = $(CLIENT_LIB) +queue_receiver_SOURCES = queue_receiver.cpp +queue_receiver_LDADD = $(CLIENT_LIB) +topic_sender_SOURCES = topic_sender.cpp +topic_sender_LDADD = $(CLIENT_LIB) +topic_listener_SOURCES = topic_listener.cpp +topic_listener_LDADD = $(CLIENT_LIB) +topic_receiver_SOURCES = topic_receiver.cpp +topic_receiver_LDADD = $(CLIENT_LIB) +client_SOURCES = client.cpp +client_LDADD = $(CLIENT_LIB) +server_SOURCES = server.cpp +server_LDADD = $(CLIENT_LIB) +map_sender_SOURCES = map_sender.cpp +map_sender_LDADD = $(CLIENT_LIB) +map_receiver_SOURCES = map_receiver.cpp +map_receiver_LDADD = $(CLIENT_LIB) +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/examples/makedist.mk $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/messaging/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/messaging/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) + @rm -f client$(EXEEXT) + $(CXXLINK) $(client_OBJECTS) $(client_LDADD) $(LIBS) +map_receiver$(EXEEXT): $(map_receiver_OBJECTS) $(map_receiver_DEPENDENCIES) + @rm -f map_receiver$(EXEEXT) + $(CXXLINK) $(map_receiver_OBJECTS) $(map_receiver_LDADD) $(LIBS) +map_sender$(EXEEXT): $(map_sender_OBJECTS) $(map_sender_DEPENDENCIES) + @rm -f map_sender$(EXEEXT) + $(CXXLINK) $(map_sender_OBJECTS) $(map_sender_LDADD) $(LIBS) +queue_listener$(EXEEXT): $(queue_listener_OBJECTS) $(queue_listener_DEPENDENCIES) + @rm -f queue_listener$(EXEEXT) + $(CXXLINK) $(queue_listener_OBJECTS) $(queue_listener_LDADD) $(LIBS) +queue_receiver$(EXEEXT): $(queue_receiver_OBJECTS) $(queue_receiver_DEPENDENCIES) + @rm -f queue_receiver$(EXEEXT) + $(CXXLINK) $(queue_receiver_OBJECTS) $(queue_receiver_LDADD) $(LIBS) +queue_sender$(EXEEXT): $(queue_sender_OBJECTS) $(queue_sender_DEPENDENCIES) + @rm -f queue_sender$(EXEEXT) + $(CXXLINK) $(queue_sender_OBJECTS) $(queue_sender_LDADD) $(LIBS) +server$(EXEEXT): $(server_OBJECTS) $(server_DEPENDENCIES) + @rm -f server$(EXEEXT) + $(CXXLINK) $(server_OBJECTS) $(server_LDADD) $(LIBS) +topic_listener$(EXEEXT): $(topic_listener_OBJECTS) $(topic_listener_DEPENDENCIES) + @rm -f topic_listener$(EXEEXT) + $(CXXLINK) $(topic_listener_OBJECTS) $(topic_listener_LDADD) $(LIBS) +topic_receiver$(EXEEXT): $(topic_receiver_OBJECTS) $(topic_receiver_DEPENDENCIES) + @rm -f topic_receiver$(EXEEXT) + $(CXXLINK) $(topic_receiver_OBJECTS) $(topic_receiver_LDADD) $(LIBS) +topic_sender$(EXEEXT): $(topic_sender_OBJECTS) $(topic_sender_DEPENDENCIES) + @rm -f topic_sender$(EXEEXT) + $(CXXLINK) $(topic_sender_OBJECTS) $(topic_sender_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map_receiver.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map_sender.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue_listener.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue_receiver.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/queue_sender.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topic_listener.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topic_receiver.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topic_sender.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +$(MAKEDIST): Makefile + mkdir -p .libs + @(echo CXX=$(CXX) ; \ + echo CXXFLAGS=$(CXXFLAGS) ; \ + echo LDFLAGS=$(MAKELDFLAGS) ; \ + echo ; \ + echo all: $(noinst_PROGRAMS) ; \ + echo ; \ + echo clean: ; \ + echo " rm -f $(noinst_PROGRAMS)" ; \ + ) > $(MAKEDIST) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/cpp/examples/messaging/client.cpp b/cpp/examples/messaging/client.cpp new file mode 100644 index 0000000000..45c065880b --- /dev/null +++ b/cpp/examples/messaging/client.cpp @@ -0,0 +1,76 @@ +/* + * + * 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 <qpid/messaging/Address.h> +#include <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Receiver.h> +#include <qpid/messaging/Sender.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + + Sender sender = session.createSender("service_queue"); + + //create temp queue & receiver... + Address responseQueue = session.createTempQueue(); + Receiver receiver = session.createReceiver(responseQueue); + + // Now send some messages ... + string s[] = { + "Twas brillig, and the slithy toves", + "Did gire and gymble in the wabe.", + "All mimsy were the borogroves,", + "And the mome raths outgrabe." + }; + + Message request; + request.setReplyTo(responseQueue); + for (int i=0; i<4; i++) { + request.setContent(s[i]); + sender.send(request); + Message response = receiver.fetch(); + std::cout << request.getContent().asString() << " -> " << response.getContent().asString() << std::endl; + } + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/map_receiver.cpp b/cpp/examples/messaging/map_receiver.cpp new file mode 100644 index 0000000000..e6557b1560 --- /dev/null +++ b/cpp/examples/messaging/map_receiver.cpp @@ -0,0 +1,54 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Receiver.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + Receiver receiver = session.createReceiver("message_queue"); + Message message = receiver.fetch(); + std::cout << message.getContent().asMap() << std::endl; + session.acknowledge(); + receiver.cancel(); + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} diff --git a/cpp/examples/messaging/map_sender.cpp b/cpp/examples/messaging/map_sender.cpp new file mode 100644 index 0000000000..9301c1fe1f --- /dev/null +++ b/cpp/examples/messaging/map_sender.cpp @@ -0,0 +1,66 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Sender.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + Sender sender = session.createSender("message_queue"); + + Message message; + message.getContent()["id"] = 987654321; + message.getContent()["name"] = "Widget"; + message.getContent()["price"] = 0.99;//bad use of floating point number, just an example! + Variant::List colours; + colours.push_back(Variant("red")); + colours.push_back(Variant("green")); + colours.push_back(Variant("white")); + message.getContent()["colours"] = colours; + + sender.send(message); + session.sync(); + + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/queue_listener.cpp b/cpp/examples/messaging/queue_listener.cpp new file mode 100644 index 0000000000..099e8e145a --- /dev/null +++ b/cpp/examples/messaging/queue_listener.cpp @@ -0,0 +1,82 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Session.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/MessageListener.h> +#include <qpid/messaging/Receiver.h> + +#include <cstdlib> +#include <iostream> + +using namespace qpid::messaging; + +class Listener : public MessageListener +{ + public: + Listener(const Receiver& receiver); + void received(Message& message); + bool isFinished(); + private: + Receiver receiver; + bool finished; +}; + +Listener::Listener(const Receiver& r) : receiver(r), finished(false) {} + +bool Listener::isFinished() { return finished; } + +void Listener::received(Message& message) +{ + std::cout << "Message: " << message.getContent().asString() << std::endl; + if (message.getContent().asString() == "That's all, folks!") { + std::cout << "Shutting down listener" << std::endl; + receiver.cancel(); + finished = true; + } +} + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + + Receiver receiver = session.createReceiver("message_queue"); + Listener listener(receiver); + receiver.setListener(&listener); + receiver.setCapacity(1); + receiver.start(); + while (session.dispatch()) { + session.acknowledge(); + if (listener.isFinished()) break; + } + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/queue_receiver.cpp b/cpp/examples/messaging/queue_receiver.cpp new file mode 100644 index 0000000000..83a44b2ca9 --- /dev/null +++ b/cpp/examples/messaging/queue_receiver.cpp @@ -0,0 +1,65 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Receiver.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + + try { + Variant::Map options; + if (argc>2) parseOptionString(argv[2], options); + Connection connection = Connection::open(url, options); + Session session = connection.newSession(); + Receiver receiver = session.createReceiver("message_queue"); + while (true) { + Message message = receiver.fetch(); + std::cout << "Message: " << message.getContent() << std::endl; + session.acknowledge(); + if (message.getContent().asString() == "That's all, folks!") { + std::cout << "Cancelling receiver" << std::endl; + receiver.cancel(); + break; + } + } + + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/queue_sender.cpp b/cpp/examples/messaging/queue_sender.cpp new file mode 100644 index 0000000000..637e7eb8e4 --- /dev/null +++ b/cpp/examples/messaging/queue_sender.cpp @@ -0,0 +1,65 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Sender.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + int count = argc>2 ? atoi(argv[2]) : 10; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + Sender sender = session.createSender("message_queue"); + + // Now send some messages ... + for (int i=0; i<count; i++) { + Message message; + message.getContent() << "Message " << i; + sender.send(message); + } + + // And send a final message to indicate termination. + Message message("That's all, folks!"); + sender.send(message); + session.sync(); + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/server.cpp b/cpp/examples/messaging/server.cpp new file mode 100644 index 0000000000..6f0f2af02d --- /dev/null +++ b/cpp/examples/messaging/server.cpp @@ -0,0 +1,78 @@ +/* + * + * 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 <qpid/messaging/Address.h> +#include <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Receiver.h> +#include <qpid/messaging/Sender.h> +#include <qpid/messaging/Session.h> +#include <qpid/messaging/Variant.h> + +#include <algorithm> +#include <cstdlib> +#include <iostream> +#include <memory> +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + VariantMap options; + options["auto_acknowledge"] = 0; + Receiver receiver = session.createReceiver("service_queue", options); + + while (true) { + Message request = receiver.fetch(); + const Address& address = request.getReplyTo(); + if (address) { + Sender sender = session.createSender(address); + std::string s = request.getContent().asString(); + std::transform(s.begin(), s.end(), s.begin(), toupper); + Message response(s); + sender.send(response); + std::cout << "Processed request: " + << request.getContent().asString() + << " -> " + << response.getContent().asString() << std::endl; + session.acknowledge(); + } else { + std::cerr << "Error: no reply address specified for request: " << request.getContent().asString() << std::endl; + session.reject(request); + } + } + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/topic_listener.cpp b/cpp/examples/messaging/topic_listener.cpp new file mode 100644 index 0000000000..6b625e13b8 --- /dev/null +++ b/cpp/examples/messaging/topic_listener.cpp @@ -0,0 +1,82 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Filter.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/MessageListener.h> +#include <qpid/messaging/Session.h> +#include <qpid/messaging/Receiver.h> + +#include <cstdlib> +#include <iostream> + +using namespace qpid::messaging; + +class Listener : public MessageListener +{ + public: + Listener(const Receiver& receiver); + void received(Message& message); + bool isFinished(); + private: + Receiver receiver; + bool finished; +}; + +Listener::Listener(const Receiver& r) : receiver(r), finished(false) {} + +bool Listener::isFinished() { return finished; } + +void Listener::received(Message& message) +{ + std::cout << "Message: " << message.getContent().asString() << std::endl; + if (message.getContent().asString() == "That's all, folks!") { + std::cout << "Shutting down listener" << std::endl; + receiver.cancel(); + finished = true; + } +} + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + const char* pattern = argc>2 ? argv[2] : "#.#"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + + Filter filter(Filter::WILDCARD, pattern, "control"); + Receiver receiver = session.createReceiver("news_service", filter); + Listener listener(receiver); + receiver.setListener(&listener); + receiver.setCapacity(1); + receiver.start(); + while (session.dispatch() && !listener.isFinished()); + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/topic_receiver.cpp b/cpp/examples/messaging/topic_receiver.cpp new file mode 100644 index 0000000000..063f0d9cb0 --- /dev/null +++ b/cpp/examples/messaging/topic_receiver.cpp @@ -0,0 +1,66 @@ +/* + * + * 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 <qpid/messaging/Address.h> +#include <qpid/messaging/Connection.h> +#include <qpid/messaging/Filter.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Receiver.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + const char* pattern = argc>2 ? argv[2] : "#.#"; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + Filter filter(Filter::WILDCARD, pattern, "control"); + Receiver receiver = session.createReceiver(Address("news_service", "topic"), filter); + while (true) { + Message message = receiver.fetch(); + std::cout << "Message: " << message.getContent().asString() << std::endl; + if (message.getContent().asString() == "That's all, folks!") { + std::cout << "Cancelling receiver" << std::endl; + receiver.cancel(); + break; + } + } + + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + diff --git a/cpp/examples/messaging/topic_sender.cpp b/cpp/examples/messaging/topic_sender.cpp new file mode 100644 index 0000000000..5665fc45f9 --- /dev/null +++ b/cpp/examples/messaging/topic_sender.cpp @@ -0,0 +1,78 @@ +/* + * + * 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 <qpid/messaging/Connection.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Sender.h> +#include <qpid/messaging/Session.h> + +#include <cstdlib> +#include <iostream> + +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +void sendMessages(Sender& sender, int count, const std::string& subject, const std::string& text) +{ + Message message; + message.setSubject(subject); + for (int i=0; i<count; i++) { + stringstream message_data; + message_data << text << i; + + message.setContent(message_data.str()); + sender.send(message); + } +} + +int main(int argc, char** argv) { + const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + int count = argc>2 ? atoi(argv[2]) : 10; + + try { + Connection connection = Connection::open(url); + Session session = connection.newSession(); + Sender sender = session.createSender("news_service"); + + // Now send some messages to each topic... + sendMessages(sender, count, "usa.news", "news about the usa"); + sendMessages(sender, count, "usa.weather", "weather report for the usa"); + sendMessages(sender, count, "europe.news", "news about europe"); + sendMessages(sender, count, "europe.weather", "weather report for europe"); + + // And send a final message to indicate termination. + Message message("That's all, folks!"); + message.setSubject("control"); + sender.send(message); + session.sync(); + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + } + return 1; +} + + |