summaryrefslogtreecommitdiffstats
path: root/contrib/omrabbitmq
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--contrib/omrabbitmq/Makefile.am8
-rw-r--r--contrib/omrabbitmq/Makefile.in798
-rw-r--r--contrib/omrabbitmq/omrabbitmq.c1381
3 files changed, 2187 insertions, 0 deletions
diff --git a/contrib/omrabbitmq/Makefile.am b/contrib/omrabbitmq/Makefile.am
new file mode 100644
index 0000000..4c882f0
--- /dev/null
+++ b/contrib/omrabbitmq/Makefile.am
@@ -0,0 +1,8 @@
+pkglib_LTLIBRARIES = omrabbitmq.la
+
+omrabbitmq_la_SOURCES = omrabbitmq.c
+omrabbitmq_la_CPPFLAGS = $(RABBITMQ_CFLAGS) $(RSRT_CFLAGS) $(PTHREADS_CFLAGS)
+omrabbitmq_la_LDFLAGS = -module -avoid-version
+omrabbitmq_la_LIBADD = $(RABBITMQ_LIBS)
+
+EXTRA_DIST =
diff --git a/contrib/omrabbitmq/Makefile.in b/contrib/omrabbitmq/Makefile.in
new file mode 100644
index 0000000..7765692
--- /dev/null
+++ b/contrib/omrabbitmq/Makefile.in
@@ -0,0 +1,798 @@
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2018 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@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+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@
+subdir = contrib/omrabbitmq
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_define.m4 \
+ $(top_srcdir)/m4/atomic_operations.m4 \
+ $(top_srcdir)/m4/atomic_operations_64bit.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)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+omrabbitmq_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_omrabbitmq_la_OBJECTS = omrabbitmq_la-omrabbitmq.lo
+omrabbitmq_la_OBJECTS = $(am_omrabbitmq_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+omrabbitmq_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(omrabbitmq_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/omrabbitmq_la-omrabbitmq.Plo
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(omrabbitmq_la_SOURCES)
+DIST_SOURCES = $(omrabbitmq_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APU_CFLAGS = @APU_CFLAGS@
+APU_LIBS = @APU_LIBS@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CIVETWEB_LIBS = @CIVETWEB_LIBS@
+CONF_FILE_PATH = @CONF_FILE_PATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CURL_CFLAGS = @CURL_CFLAGS@
+CURL_LIBS = @CURL_LIBS@
+CYGPATH_W = @CYGPATH_W@
+CZMQ_CFLAGS = @CZMQ_CFLAGS@
+CZMQ_LIBS = @CZMQ_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DL_LIBS = @DL_LIBS@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FAUP_LIBS = @FAUP_LIBS@
+FGREP = @FGREP@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
+GNUTLS_LIBS = @GNUTLS_LIBS@
+GREP = @GREP@
+GSS_LIBS = @GSS_LIBS@
+GT_KSI_LS12_CFLAGS = @GT_KSI_LS12_CFLAGS@
+GT_KSI_LS12_LIBS = @GT_KSI_LS12_LIBS@
+HASH_XXHASH_LIBS = @HASH_XXHASH_LIBS@
+HIREDIS_CFLAGS = @HIREDIS_CFLAGS@
+HIREDIS_LIBS = @HIREDIS_LIBS@
+IMUDP_LIBS = @IMUDP_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+IP = @IP@
+JAVA = @JAVA@
+JAVAC = @JAVAC@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBCAPNG_CFLAGS = @LIBCAPNG_CFLAGS@
+LIBCAPNG_LIBS = @LIBCAPNG_LIBS@
+LIBCAPNG_PRESENT_CFLAGS = @LIBCAPNG_PRESENT_CFLAGS@
+LIBCAPNG_PRESENT_LIBS = @LIBCAPNG_PRESENT_LIBS@
+LIBDBI_CFLAGS = @LIBDBI_CFLAGS@
+LIBDBI_LIBS = @LIBDBI_LIBS@
+LIBESTR_CFLAGS = @LIBESTR_CFLAGS@
+LIBESTR_LIBS = @LIBESTR_LIBS@
+LIBEVENT_CFLAGS = @LIBEVENT_CFLAGS@
+LIBEVENT_LIBS = @LIBEVENT_LIBS@
+LIBFASTJSON_CFLAGS = @LIBFASTJSON_CFLAGS@
+LIBFASTJSON_LIBS = @LIBFASTJSON_LIBS@
+LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
+LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
+LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
+LIBLOGGING_CFLAGS = @LIBLOGGING_CFLAGS@
+LIBLOGGING_LIBS = @LIBLOGGING_LIBS@
+LIBLOGGING_STDLOG_CFLAGS = @LIBLOGGING_STDLOG_CFLAGS@
+LIBLOGGING_STDLOG_LIBS = @LIBLOGGING_STDLOG_LIBS@
+LIBLOGNORM_CFLAGS = @LIBLOGNORM_CFLAGS@
+LIBLOGNORM_LIBS = @LIBLOGNORM_LIBS@
+LIBLZ4_CFLAGS = @LIBLZ4_CFLAGS@
+LIBLZ4_LIBS = @LIBLZ4_LIBS@
+LIBM = @LIBM@
+LIBMONGOC_CFLAGS = @LIBMONGOC_CFLAGS@
+LIBMONGOC_LIBS = @LIBMONGOC_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBRDKAFKA_CFLAGS = @LIBRDKAFKA_CFLAGS@
+LIBRDKAFKA_LIBS = @LIBRDKAFKA_LIBS@
+LIBS = @LIBS@
+LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@
+LIBSYSTEMD_JOURNAL_CFLAGS = @LIBSYSTEMD_JOURNAL_CFLAGS@
+LIBSYSTEMD_JOURNAL_LIBS = @LIBSYSTEMD_JOURNAL_LIBS@
+LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@
+LIBTOOL = @LIBTOOL@
+LIBUUID_CFLAGS = @LIBUUID_CFLAGS@
+LIBUUID_LIBS = @LIBUUID_LIBS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_CONFIG = @MYSQL_CONFIG@
+MYSQL_LIBS = @MYSQL_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PGSQL_CFLAGS = @PGSQL_CFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PG_CONFIG = @PG_CONFIG@
+PID_FILE_PATH = @PID_FILE_PATH@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PROTON_CFLAGS = @PROTON_CFLAGS@
+PROTON_LIBS = @PROTON_LIBS@
+PROTON_PROACTOR_CFLAGS = @PROTON_PROACTOR_CFLAGS@
+PROTON_PROACTOR_LIBS = @PROTON_PROACTOR_LIBS@
+PTHREADS_CFLAGS = @PTHREADS_CFLAGS@
+PTHREADS_LIBS = @PTHREADS_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RABBITMQ_CFLAGS = @RABBITMQ_CFLAGS@
+RABBITMQ_LIBS = @RABBITMQ_LIBS@
+RANLIB = @RANLIB@
+READLINK = @READLINK@
+REDIS = @REDIS@
+RELP_CFLAGS = @RELP_CFLAGS@
+RELP_LIBS = @RELP_LIBS@
+RSRT_CFLAGS = @RSRT_CFLAGS@
+RSRT_CFLAGS1 = @RSRT_CFLAGS1@
+RSRT_LIBS = @RSRT_LIBS@
+RSRT_LIBS1 = @RSRT_LIBS1@
+RST2MAN = @RST2MAN@
+RT_LIBS = @RT_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SNMP_CFLAGS = @SNMP_CFLAGS@
+SNMP_LIBS = @SNMP_LIBS@
+SOL_LIBS = @SOL_LIBS@
+STRIP = @STRIP@
+TCL_BIN_DIR = @TCL_BIN_DIR@
+TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
+TCL_LIB_FILE = @TCL_LIB_FILE@
+TCL_LIB_FLAG = @TCL_LIB_FLAG@
+TCL_LIB_SPEC = @TCL_LIB_SPEC@
+TCL_PATCH_LEVEL = @TCL_PATCH_LEVEL@
+TCL_SRC_DIR = @TCL_SRC_DIR@
+TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@
+TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@
+TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
+TCL_VERSION = @TCL_VERSION@
+UDPSPOOF_CFLAGS = @UDPSPOOF_CFLAGS@
+UDPSPOOF_LIBS = @UDPSPOOF_LIBS@
+VALGRIND = @VALGRIND@
+VERSION = @VERSION@
+WARN_CFLAGS = @WARN_CFLAGS@
+WARN_LDFLAGS = @WARN_LDFLAGS@
+WARN_SCANNERFLAGS = @WARN_SCANNERFLAGS@
+WGET = @WGET@
+YACC = @YACC@
+YACC_FOUND = @YACC_FOUND@
+YFLAGS = @YFLAGS@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
+ZSTD_CFLAGS = @ZSTD_CFLAGS@
+ZSTD_LIBS = @ZSTD_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+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@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moddirs = @moddirs@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+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@
+pkglib_LTLIBRARIES = omrabbitmq.la
+omrabbitmq_la_SOURCES = omrabbitmq.c
+omrabbitmq_la_CPPFLAGS = $(RABBITMQ_CFLAGS) $(RSRT_CFLAGS) $(PTHREADS_CFLAGS)
+omrabbitmq_la_LDFLAGS = -module -avoid-version
+omrabbitmq_la_LIBADD = $(RABBITMQ_LIBS)
+EXTRA_DIST =
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(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 contrib/omrabbitmq/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu contrib/omrabbitmq/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__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ 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):
+
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+omrabbitmq.la: $(omrabbitmq_la_OBJECTS) $(omrabbitmq_la_DEPENDENCIES) $(EXTRA_omrabbitmq_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(omrabbitmq_la_LINK) -rpath $(pkglibdir) $(omrabbitmq_la_OBJECTS) $(omrabbitmq_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omrabbitmq_la-omrabbitmq.Plo@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+omrabbitmq_la-omrabbitmq.lo: omrabbitmq.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(omrabbitmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT omrabbitmq_la-omrabbitmq.lo -MD -MP -MF $(DEPDIR)/omrabbitmq_la-omrabbitmq.Tpo -c -o omrabbitmq_la-omrabbitmq.lo `test -f 'omrabbitmq.c' || echo '$(srcdir)/'`omrabbitmq.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/omrabbitmq_la-omrabbitmq.Tpo $(DEPDIR)/omrabbitmq_la-omrabbitmq.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='omrabbitmq.c' object='omrabbitmq_la-omrabbitmq.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(omrabbitmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o omrabbitmq_la-omrabbitmq.lo `test -f 'omrabbitmq.c' || echo '$(srcdir)/'`omrabbitmq.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(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 $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+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:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+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-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/omrabbitmq_la-omrabbitmq.Plo
+ -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-pkglibLTLIBRARIES
+
+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 -f ./$(DEPDIR)/omrabbitmq_la-omrabbitmq.Plo
+ -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: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+ clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ cscopelist-am ctags ctags-am 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-pkglibLTLIBRARIES 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 tags-am uninstall \
+ uninstall-am uninstall-pkglibLTLIBRARIES
+
+.PRECIOUS: Makefile
+
+
+# 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/contrib/omrabbitmq/omrabbitmq.c b/contrib/omrabbitmq/omrabbitmq.c
new file mode 100644
index 0000000..16c69ca
--- /dev/null
+++ b/contrib/omrabbitmq/omrabbitmq.c
@@ -0,0 +1,1381 @@
+/* omrabbitmq.c
+ *
+ * This output plugin enables rsyslog to send messages to the RabbitMQ.
+ *
+ * Copyright 2012-2013 Vaclav Tomec
+ * Copyright 2014 Rainer Gerhards
+ * Copyright 2022 Hamid Maadani
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Vaclav Tomec
+ * <vaclav.tomec@gmail.com>
+ *
+ * TLS & AMQP heartbeat support added by:
+ * Hamid Maadani
+ * <hamid@dexo.tech>
+ *
+ */
+#include "config.h"
+#include <pthread.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <signal.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "rsyslog.h"
+#include "conf.h"
+#include "syslogd-types.h"
+#include "srUtils.h"
+#include "template.h"
+#include "module-template.h"
+#include "errmsg.h"
+#include "cfsysline.h"
+#include "debug.h"
+#include "datetime.h"
+#include "rsconf.h"
+
+#include <sys/socket.h>
+
+#include "amqp.h"
+#include "amqp_framing.h"
+#include "amqp_tcp_socket.h"
+#include "amqp_ssl_socket.h"
+#if (AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR < 4)
+#error "rabbitmq-c version must be >= 0.4.0"
+#endif
+
+#define RABBITMQ_CHANNEL 1
+
+MODULE_TYPE_OUTPUT
+MODULE_TYPE_NOKEEP
+MODULE_CNFNAME("omrabbitmq")
+
+/*
+ * internal structures
+ */
+DEF_OMOD_STATIC_DATA
+DEFobjCurrIf(glbl)
+DEFobjCurrIf(datetime)
+
+static int instance_counter = 0;
+static int mode_test = 0;
+
+typedef struct {
+ char *host; /* rabbitmq server fqdn or IP */
+ int port; /* rabbitmq server port */
+} server_t;
+
+typedef struct {
+ server_t s; /* rabbitmq server */
+ int failures; /* rabbitmq server failures */
+} server_wrk_t;
+
+
+typedef struct {
+ time_t return_check_interval; /* time interval between usual server health checks */
+ time_t half_return_check_interval; /* for computing */
+ time_t quick_oscillation_interval; /* time interval below which the service is not stable */
+ int quick_oscillation_max; /* number of quick oscillation after which the connection is kept on backup */
+ time_t graceful_interval; /* time interval the connection is kept on backup after which the usual server
+ * check restarts */
+ int quick_oscillation_count; /* current number of simultaneous quick oscillation detected */
+} recover_t;
+
+typedef struct _instanceData {
+ /* here you need to define all action-specific data. A record of type
+ * instanceData will be handed over to each instance of the action. Keep
+ * in mind that there may be several invocations of the same type of action
+ * inside rsyslog.conf, and this is what keeps them apart. Do NOT use
+ * static data for this!
+ */
+ amqp_bytes_t exchange; /* exchange to send message to */
+
+ amqp_bytes_t routing_key; /* fixed routing_key to use */
+ uchar *routing_key_template; /* routing_key template */
+ int idx_routing_key_template; /* routing_key template index in doAction tab */
+
+ sbool populate_properties; /* populates message properties */
+ int delivery_mode; /* delivery mode transient or persistent message */
+ amqp_bytes_t expiration; /* message expiration */
+
+ uchar *body_template; /* body template */
+ int idx_body_template; /* body template index in doAction tab */
+
+ amqp_basic_properties_t amqp_props_tpl_type; /* */
+ char *content_type; /* */
+ amqp_basic_properties_t amqp_props_plaintext; /* */
+
+ char *exchange_type; /* */
+ int durable; /* */
+ int auto_delete; /* */
+
+ int iidx;
+ int nbWrkr;
+
+ server_t server1; /* first rabbitmq server */
+ server_t server2; /* second rabbitmq server */
+
+ char *vhost; /* rabbitmq server vhost */
+ char *user; /* rabbitmq username */
+ char *password; /* rabbitmq username's password */
+
+ int ssl; /* should amqp connection be made over TLS? */
+ int initOpenSSL; /* should rabbitmq-c initialize OpenSSL? */
+ int verifyPeer; /* should peer be verified for TLS? */
+ int verifyHostname; /* should hostname be verified for TLS? */
+ int heartbeat; /* AMQP heartbeat interval in seconds (0 means disabled, which is default) */
+ char *caCert; /* CA certificate to be used for TLS connection */
+
+ recover_t recover_policy;
+
+} instanceData;
+
+typedef struct wrkrInstanceData {
+ amqp_connection_state_t a_conn; /* amqp connection */
+
+ int connected;
+ int channel_opened;
+
+ pthread_t thread; /* */
+ short thread_running; /* */
+ pthread_mutex_t send_mutex; /* */
+ pthread_cond_t cond; /* */
+
+ rsRetVal state; /* state of the connection */
+
+ server_wrk_t serverPrefered; /* usual rabbitmq server */
+ server_wrk_t serverBackup; /* backup rabbitmq server */
+ server_wrk_t *serverActive; /* active rabbitmq server */
+
+ instanceData *pData;
+
+ recover_t recover_policy;
+ time_t last_failback;
+
+ int iidx;
+ int widx;
+ int go_on;
+} wrkrInstanceData_t;
+
+typedef struct _msg2amqp_props_ {
+ propid_t id;
+ const char *name;
+ amqp_bytes_t *standardprop;
+ int flag;
+} msg2amqp_props_t;
+
+/* tables for interfacing with the v6 config system */
+/* action (instance) parameters */
+static struct cnfparamdescr actpdescr[] = {
+ { "host", eCmdHdlrString, 0 },
+ { "port", eCmdHdlrInt, 0 },
+ { "virtual_host", eCmdHdlrGetWord, 0 },
+ { "heartbeat_interval", eCmdHdlrNonNegInt, 0 },
+ { "user", eCmdHdlrGetWord, 0 },
+ { "password", eCmdHdlrGetWord, 0 },
+ { "ssl", eCmdHdlrBinary, 0 },
+ { "init_openssl", eCmdHdlrBinary, 0 },
+ { "verify_peer", eCmdHdlrBinary, 0 },
+ { "verify_hostname", eCmdHdlrBinary, 0 },
+ { "ca_cert", eCmdHdlrGetWord, 0 },
+ { "exchange", eCmdHdlrGetWord, 0 },
+ { "routing_key", eCmdHdlrGetWord, 0 },
+ { "routing_key_template", eCmdHdlrGetWord, 0 },
+ { "delivery_mode", eCmdHdlrGetWord, 0 },
+ { "expiration", eCmdHdlrNonNegInt, 0 },
+ { "populate_properties", eCmdHdlrBinary, 0 },
+ { "body_template", eCmdHdlrGetWord, 0 },
+ { "content_type", eCmdHdlrGetWord, 0 },
+ { "recover_policy", eCmdHdlrString, 0 },
+ { "exchange_type", eCmdHdlrGetWord, 0},
+ { "durable", eCmdHdlrBinary, 0},
+ { "auto_delete", eCmdHdlrBinary, 0},
+};
+static struct cnfparamblk actpblk =
+ {
+ CNFPARAMBLK_VERSION,
+ sizeof(actpdescr)/sizeof(struct cnfparamdescr),
+ actpdescr
+ };
+
+static amqp_bytes_t cstring_bytes(const char *str)
+{
+ return str ? amqp_cstring_bytes(str) : amqp_empty_bytes;
+}
+
+/* Initialize recover structure from the configuration string
+ */
+static void init_recover(recover_t *fb, char *str)
+{
+ time_t value[4] = { 0, 0, 0, 0 };
+
+ if (str && *str){
+ int i = -1;
+ do {
+ value[++i] = strtoul(str, &str, 10);
+ if (*str) str++;
+ } while (i < 3 && value[i] && *str);
+ }
+
+ fb->return_check_interval = (value[0]) ? value[0] : 60;
+ fb->half_return_check_interval = fb->return_check_interval / 2;
+ fb->quick_oscillation_interval = (value[1]) ? value[1] : (fb->return_check_interval / 10);
+ fb->quick_oscillation_max = (value[2]) ? (int)(value[2]) : 3;
+ fb->graceful_interval = (value[3]) ? value[3] : (fb->return_check_interval * 10) -
+ fb->half_return_check_interval;
+ fb->quick_oscillation_count = 0;
+}
+
+/* this method compute the delay before next reconnection attempt according
+ */
+static unsigned long next_check(recover_t *fb, time_t last_failback)
+{
+ time_t now = time(NULL);
+ srandom(now);
+
+ if (now - last_failback < fb->quick_oscillation_interval) {
+ /* quick oscillation detected */
+ fb->quick_oscillation_count++;
+
+ if (fb->quick_oscillation_count > fb->quick_oscillation_max) {
+ /* too much oscillation inserting a graceful sleep */
+ fb->quick_oscillation_count = 0;
+ return fb->graceful_interval + fb->return_check_interval * random() / RAND_MAX;
+ }
+ } else
+ fb->quick_oscillation_count = 0;
+
+ /* returning a standard delay between 0,5 and 1,5 * return_check_interval */
+ return fb->half_return_check_interval + fb->return_check_interval * random() / RAND_MAX;
+}
+
+/* authenticate to rabbitmq server and set connection parameter according to rsyslog configuration
+ */
+static int amqp_authenticate(wrkrInstanceData_t *self, amqp_connection_state_t a_conn)
+{
+ amqp_rpc_reply_t ret;
+
+ /* define the frame size */
+ int frame_size = (glbl.GetMaxLine(runConf)<130000) ? 131072 : (glbl.GetMaxLine(runConf)+1072);
+
+ /* authenticate */
+ ret = amqp_login(a_conn, (char const *)self->pData->vhost, 1, frame_size, self->pData->heartbeat,
+ AMQP_SASL_METHOD_PLAIN, self->pData->user, self->pData->password);
+
+ if (ret.reply_type != AMQP_RESPONSE_NORMAL)
+ {
+ LogError(0, RS_RET_RABBITMQ_LOGIN_ERR, "omrabbitmq module %d/%d: login to AMQP "
+ "server %s failed. (%d / %s)",
+ self->iidx, self->widx, self->serverActive->s.host, ret.reply_type,
+ amqp_error_string2(ret.library_error));
+ return 0;
+ }
+
+ /* open the communication channel */
+ amqp_channel_open(a_conn, 1);
+
+ if (amqp_get_rpc_reply(a_conn).reply_type != AMQP_RESPONSE_NORMAL)
+ {
+ LogError(0, RS_RET_RABBITMQ_CHANNEL_ERR, "omrabbitmq module %d/%d: open channel failed.",
+ self->iidx, self->widx);
+ return 0;
+ }
+
+ if (self->pData->exchange_type) {
+ /* we declare the exchange according to specifications */
+ amqp_table_t props = { 0, NULL };
+ #if (AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR < 6)
+ amqp_exchange_declare(a_conn, 1, self->pData->exchange, cstring_bytes(self->pData->exchange_type),
+ 0, self->pData->durable, props);
+ #else
+ amqp_exchange_declare(a_conn, 1, self->pData->exchange, cstring_bytes(self->pData->exchange_type),
+ 0, self->pData->durable, self->pData->auto_delete, 0, props);
+ #endif
+
+ if (amqp_get_rpc_reply(a_conn).reply_type != AMQP_RESPONSE_NORMAL)
+ {
+ /* if a problem occurs on declaring the exchange we receive a channel_close with the
+ * error then we can log the error, respond a channel_close_ok and reopen it
+ * so we can work with the existing exchange.
+ */
+ amqp_channel_close_ok_t chan_cls_ok;
+ amqp_channel_close_t *chan_cls =
+ (amqp_channel_close_t*)amqp_get_rpc_reply(a_conn).reply.decoded;
+
+ if (amqp_get_rpc_reply(a_conn).reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION) {
+ LogError(0, RS_RET_RABBITMQ_CHANNEL_ERR,
+ "omrabbitmq module %d/%d: disconnected while exchange declare (%d)",
+ self->iidx, self->widx, amqp_get_rpc_reply(a_conn).library_error);
+ return 0;
+ }
+
+ LogError(0, RS_RET_RABBITMQ_CHANNEL_ERR,
+ "omrabbitmq module %d/%d: exchange declare failed %.*s.", self->iidx, self->widx,
+ (int)chan_cls->reply_text.len, (char*)chan_cls->reply_text.bytes);
+
+ chan_cls_ok.dummy = '\0';
+ amqp_send_method(a_conn, 1, AMQP_CHANNEL_CLOSE_OK_METHOD, &chan_cls_ok);
+
+ /* reopen the communication channel in case of error it should be close by server*/
+ amqp_channel_open(a_conn, 1);
+
+ if (amqp_get_rpc_reply(a_conn).reply_type != AMQP_RESPONSE_NORMAL)
+ {
+ LogError(0, RS_RET_RABBITMQ_CHANNEL_ERR, "omrabbitmq module %d/%d: "
+ "open channel failed.", self->iidx, self->widx);
+ return 0;
+ }
+
+ }
+ }
+ /* release the buffers if possible */
+ amqp_maybe_release_buffers(a_conn);
+
+ return 1;
+}
+
+/* This method establish a new connection
+ * @self pointer on the worker datas
+ * @server pointer on the server datas (preferred or backup)
+ * @return the connection state or NULL on error
+ */
+static amqp_connection_state_t tryConnection(wrkrInstanceData_t *self, server_t *server)
+{
+ int retconn = 0;
+ struct timeval delay;
+ delay.tv_sec = 1;
+ delay.tv_usec = 0;
+ amqp_socket_t *sockfd = NULL;
+
+ amqp_connection_state_t a_conn = amqp_new_connection();
+ if (a_conn) {
+ if (self->pData->ssl) {
+ if (!self->pData->initOpenSSL) {
+ // prevent OpenSSL double initialization
+ amqp_set_initialize_ssl_library(0);
+ }
+ sockfd = amqp_ssl_socket_new(a_conn);
+ } else {
+ sockfd = amqp_tcp_socket_new(a_conn);
+ }
+ }
+
+ if (sockfd)
+ {
+ if (self->pData->ssl) {
+#if (AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR < 8)
+ amqp_ssl_socket_set_verify(sockfd, self->pData->verifyPeer);
+#else
+ amqp_ssl_socket_set_verify_peer(sockfd, self->pData->verifyPeer);
+ amqp_ssl_socket_set_verify_hostname(sockfd, self->pData->verifyHostname);
+#endif
+ if (self->pData->caCert) {
+ amqp_ssl_socket_set_cacert(sockfd, self->pData->caCert);
+ }
+ }
+
+ LogError(0, RS_RET_RABBITMQ_CHANNEL_ERR,
+ "omrabbitmq module %d/%d: server %s port %d.", self->iidx, self->widx,
+ server->host, server->port);
+
+ #if defined(_AIX)
+ retconn = amqp_socket_open(sockfd, server->host, server->port);
+ #else
+ retconn = amqp_socket_open_noblock(sockfd, (const char*)server->host, server->port, &delay);
+ #endif
+ }
+
+ if (retconn == AMQP_STATUS_OK && amqp_authenticate(self, a_conn))
+ return a_conn;
+
+ /* the connection failed so free it and return NULL */
+ amqp_connection_close(a_conn, 200);
+ amqp_destroy_connection(a_conn);
+#if ((AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR > 8)) || (AMQP_VERSION_MAJOR > 0)
+ if (self->pData->ssl && self->pData->initOpenSSL) {
+ amqp_uninitialize_ssl_library();
+ }
+#endif
+
+ return NULL;
+}
+
+static int manage_connection(wrkrInstanceData_t *self, amqp_frame_t *pFrame)
+{
+ int result;
+
+ pthread_mutex_unlock(&self->send_mutex);
+
+ do {
+ if (self->serverActive == &self->serverBackup)
+ {
+ amqp_connection_state_t new_conn;
+ struct timeval delay;
+
+ /* The worker is connected to the backup server.
+ * next_check function compute the delay before trying to recover
+ * the connection to the preferred server according to recover_policy
+ */
+ delay.tv_sec = next_check(&self->recover_policy, self->last_failback);
+ delay.tv_usec = 0;
+
+ result = amqp_simple_wait_frame_noblock(self->a_conn, pFrame, &delay);
+
+ /* if connected to backup server then check if usual server is alive.
+ * if so then disconnect from backup */
+ if (result == AMQP_STATUS_TIMEOUT &&
+ (new_conn = tryConnection(self,
+ &(self->serverPrefered.s)))
+ != NULL) {
+ /* connection is re-established to preferred server so
+ * swap connections */
+ amqp_connection_state_t old_conn = self->a_conn;
+
+ /* now lock to avoid message publishing. */
+ pthread_mutex_lock(&self->send_mutex);
+ self->a_conn = new_conn;
+ self->serverActive = &self->serverPrefered;
+ self->serverActive->failures = 0;
+ pthread_mutex_unlock(&self->send_mutex);
+ /* back to unlock mode */
+
+ DBGPRINTF("omrabbitmq module %d: reconnects to usual server.\n",
+ self->iidx);
+ amqp_connection_close(old_conn, 200);
+ amqp_destroy_connection(old_conn);
+#if ((AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR > 8)) || (AMQP_VERSION_MAJOR > 0)
+ if (self->pData->ssl && self->pData->initOpenSSL) {
+ amqp_uninitialize_ssl_library();
+ }
+#endif
+ }
+
+ } else {
+
+ result = amqp_simple_wait_frame(self->a_conn, pFrame);
+
+ }
+ } while(result == AMQP_STATUS_TIMEOUT);
+
+ /* now lock the mutex to avoid message publishing. */
+ pthread_mutex_lock(&self->send_mutex);
+
+ return result;
+}
+
+static void send_connection_close(amqp_connection_state_t state) {
+ amqp_connection_close_t *req = malloc(sizeof(amqp_connection_close_t));
+ memset(req, 0, sizeof(amqp_connection_close_t));
+ req->reply_code = 200;
+ req->reply_text.bytes = (void*)"200";
+ req->reply_text.len = 3;
+ req->class_id = (uint16_t)(AMQP_CONNECTION_CLOSE_METHOD >> 16);
+ req->method_id = (uint16_t)(AMQP_CONNECTION_CLOSE_METHOD & 0xFFFF);
+ amqp_send_method(state, 0, AMQP_CONNECTION_CLOSE_METHOD, req);
+ free(req);
+}
+
+static void send_channel_close(amqp_connection_state_t state, amqp_channel_t ch) {
+ amqp_channel_close_t *req = malloc(sizeof(amqp_channel_close_t));
+ memset(req, 0, sizeof(amqp_channel_close_t));
+ req->reply_code = 200;
+ req->reply_text.bytes = (void*)"200";
+ req->reply_text.len = 3;
+ req->class_id = (uint16_t)(AMQP_CHANNEL_CLOSE_METHOD >> 16);
+ req->method_id = (uint16_t)(AMQP_CHANNEL_CLOSE_METHOD & 0xFFFF);
+ amqp_send_method(state, ch, AMQP_CHANNEL_CLOSE_METHOD, req);
+ free(req);
+}
+
+static void send_connection_close_ok(amqp_connection_state_t state) {
+ amqp_connection_close_ok_t *req = malloc(sizeof(amqp_connection_close_ok_t));
+ memset(req, 0, sizeof(amqp_connection_close_ok_t));
+ req->dummy = '\0';
+ amqp_send_method(state, 0, AMQP_CONNECTION_CLOSE_OK_METHOD, req);
+ free(req);
+}
+
+static void send_channel_close_ok(amqp_connection_state_t state, amqp_channel_t ch) {
+ amqp_channel_close_ok_t *req = malloc(sizeof(amqp_channel_close_ok_t));
+ memset(req, 0, sizeof(amqp_channel_close_ok_t));
+ req->dummy = '\0';
+ amqp_send_method(state, ch, AMQP_CHANNEL_CLOSE_OK_METHOD, req);
+ free(req);
+}
+
+/* run_connection_routine is the thread monitoring of the rabbitmq connection.
+ * This method manage reconnection to preferred and backup servers apply the recover_policy
+ */
+static void* run_connection_routine(void* arg)
+{
+ wrkrInstanceData_t *self = (wrkrInstanceData_t *) arg;
+ amqp_frame_t frm;
+ int result;
+ self->connected = 0;
+ self->channel_opened = 0;
+ rsRetVal state_out = RS_RET_SUSPENDED;
+
+ dbgSetThrdName((uchar*)"amqp connection");
+
+ /* now lock to avoid message publishing during part of the thread loop */
+ pthread_mutex_lock(&self->send_mutex);
+
+ self->thread_running = 1;
+
+ self->state = RS_RET_OK;
+
+ srSleep(0,100);
+
+ DBGPRINTF("omrabbitmq module %d/%d: connection thread started\n", self->iidx, self->widx);
+
+ int go_on = self->go_on;
+
+ while (go_on) // this loop is used to reconnect on connection failure
+ {
+ if (self->a_conn != NULL)
+ {
+ amqp_connection_close(self->a_conn, 200);
+ amqp_destroy_connection(self->a_conn);
+#if ((AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR > 8)) || (AMQP_VERSION_MAJOR > 0)
+ if (self->pData->ssl && self->pData->initOpenSSL) {
+ amqp_uninitialize_ssl_library();
+ }
+#endif
+ }
+
+ self->a_conn = NULL;
+
+ if (!self->go_on)
+ {
+ go_on = 0;
+ state_out = RS_RET_DISABLE_ACTION;
+ continue; /* lets go back to wile (go_on) and leave cleanly */
+ }
+
+ if (self->serverActive == &self->serverBackup) {
+ self->serverBackup.failures = 0;
+ self->serverPrefered.failures = 0;
+ self->serverActive = &self->serverPrefered;
+ }
+
+ do { /* this loop tries 3 times per server before switching servers */
+ if ((self->a_conn = tryConnection(self, &(self->serverActive->s))) != NULL) {
+ self->serverActive->failures = 0;
+ } else {
+ /* set 1 second before retry */
+ struct timeval delay;
+
+ delay.tv_sec = 1;
+ delay.tv_usec = 0;
+
+ self->serverActive->failures++;
+
+ /* if 3 tries */
+ if (self->serverActive->failures == 3) {
+
+ if (!self->serverBackup.s.host || self->serverBackup.failures == 3)
+ {
+ LogError(0, RS_RET_RABBITMQ_CONN_ERR, "omrabbitmq module connection "
+ "failed 3 times on each server.");
+ }
+
+ if (self->serverActive == &self->serverBackup) {
+ self->serverBackup.failures = 0;
+ self->serverPrefered.failures = 0;
+ self->serverActive = &self->serverPrefered;
+ } else {
+ /* on usual server switch to backup server */
+ if (self->serverBackup.s.host)
+ self->serverActive = &self->serverBackup;
+ else
+ self->serverPrefered.failures = 0;
+ }
+ /* set 5 second before new round trip */
+ delay.tv_sec = 5;
+ }
+ select(0,NULL,NULL,NULL,&delay);
+ }
+ }
+ while (self->a_conn == NULL && self->go_on);
+
+ if (!self->go_on)
+ {
+ go_on = 0;
+ state_out = RS_RET_DISABLE_ACTION;
+ continue; /* lets go back to wile (go_on) and leave cleanly */
+ }
+
+ /* signal that the thread is started */
+ pthread_cond_signal(&self->cond);
+
+ self->connected = 1;
+ self->channel_opened = 1;
+
+ DBGPRINTF("omrabbitmq module %d: connected.\n", self->iidx);
+
+ self->state = RS_RET_OK;
+
+ if (self->serverActive == &self->serverBackup)
+ self->last_failback = time(NULL);
+
+ while (self->connected) // this loop is used to manage an established connection
+ {
+
+ result = manage_connection(self, &frm);
+
+ switch (result)
+ {
+ case AMQP_STATUS_NO_MEMORY:
+ LogError(0, RS_RET_OUT_OF_MEMORY, "omrabbitmq module %d/%d: no memory "
+ ": aborting module.", self->iidx, self->widx);
+ go_on = 0; /* non recoverable error let's go out */
+ self->connected = 0;
+ state_out = RS_RET_DISABLE_ACTION;
+ break;
+ case AMQP_STATUS_BAD_AMQP_DATA:
+ LogError(0, RS_RET_RABBITMQ_CONN_ERR, "omrabbitmq module %d/%d: bad "
+ "data received : reconnect.", self->iidx, self->widx);
+ self->connected = 0;
+ break;
+ case AMQP_STATUS_SOCKET_ERROR:
+ LogError(0, RS_RET_RABBITMQ_CONN_ERR, "omrabbitmq module %d/%d: Socket"
+ " error : reconnect.", self->iidx, self->widx);
+ self->connected = 0;
+ break;
+ case AMQP_STATUS_CONNECTION_CLOSED:
+ LogError(0, RS_RET_OUT_OF_MEMORY, "omrabbitmq module %d/%d: Connection"
+ " closed : reconnect.", self->iidx, self->widx);
+ self->connected = 0;
+ break;
+ case AMQP_STATUS_OK:
+ /* perhaps not a frame type so ignore it */
+ if (frm.frame_type == AMQP_FRAME_METHOD)
+ {
+ amqp_method_number_t id = frm.payload.method.id;
+ /* now handle frames from the server */
+ switch (id)
+ {
+ case AMQP_CONNECTION_CLOSE_OK_METHOD:
+
+ /* We asked to close the connection and server has responded to us */
+ self->connected = 0;
+ go_on = 0;
+ break;
+
+ case AMQP_CHANNEL_CLOSE_OK_METHOD:
+
+ /* We asked to close the channel and server has responded to us */
+ send_connection_close(self->a_conn);
+ self->channel_opened = 0;
+ break;
+
+ case AMQP_CHANNEL_CLOSE_METHOD:
+
+ /* the server wants to close the channel then the connection */
+ LogMsg(0, RS_RET_OK, LOG_WARNING,"omrabbitmq module %d/%d: "
+ "Close Channel Received (%X).", self->iidx, self->widx, id);
+ /* answer the server request & send the method */
+ send_channel_close_ok(self->a_conn, frm.channel);
+ self->channel_opened = 0;
+ break;
+
+ case AMQP_CONNECTION_CLOSE_METHOD:
+
+ /* the server want to close the connection */
+ LogMsg(0, RS_RET_OK, LOG_WARNING, "omrabbitmq module %d/%d: "
+ "Close Connection Received (%X).", self->iidx, self->widx, id);
+ /* answer the server request */
+ send_connection_close_ok(self->a_conn);
+ self->connected = 0;
+ break;
+
+ default :
+
+ LogMsg(0, RS_RET_OK, LOG_WARNING, "omrabbitmq module %d/%d: "
+ "Unmanaged amqp method received (%X) : ignored.",
+ self->iidx, self->widx, id);
+ } /* switch (frm.payload.method.id) */
+ } /* if (frm.frame_type == AMQP_FRAME_METHOD) */
+ break;
+ } /* switch (result) */
+ }
+ }
+ self->state = state_out;
+
+ /* The core ask to die so let's disconnect */
+ if (self->a_conn != NULL)
+ {
+ if (self->channel_opened)
+ amqp_channel_close(self->a_conn, 1, 200);
+ if (self->connected)
+ amqp_connection_close(self->a_conn, 200);
+ amqp_destroy_connection(self->a_conn);
+ self->a_conn = NULL;
+#if ((AMQP_VERSION_MAJOR == 0) && (AMQP_VERSION_MINOR > 8)) || (AMQP_VERSION_MAJOR > 0)
+ if (self->pData->ssl && self->pData->initOpenSSL) {
+ amqp_uninitialize_ssl_library();
+ }
+#endif
+ }
+
+ self->thread_running = 0;
+
+ /* Finishing by unlocking before the end of the thread */
+ pthread_mutex_unlock(&self->send_mutex);
+
+ /* Now notify the worker that this thread is stopping */
+ pthread_cond_signal(&self->cond);
+
+ return NULL;
+}
+
+/* ============================================================================================
+ * Main thread
+ * ============================================================================================
+ */
+
+static rsRetVal startAMQPConnection(wrkrInstanceData_t *self)
+{
+ DEFiRet;
+ pthread_mutex_lock(&self->send_mutex);
+ self->go_on = 1;
+ if (self->thread_running == 0)
+ {
+ if (!pthread_create(&self->thread, NULL, run_connection_routine, self))
+ {
+ pthread_cond_wait(&self->cond,&self->send_mutex);
+ iRet = self->state;
+ }else{
+ iRet = RS_RET_DISABLE_ACTION;
+ }
+ }
+ pthread_mutex_unlock(&self->send_mutex);
+ RETiRet;
+}
+
+static void closeAMQPConnection(wrkrInstanceData_t *self)
+{
+ if (!self || !self->a_conn) return;
+
+ void *ret;
+
+ /* Now locks to allow exclusive access to sock */
+ pthread_mutex_lock(&self->send_mutex);
+
+ self->go_on = 0;
+
+ /* send the method */
+ if (self->a_conn)
+ {
+ if (self->channel_opened){
+ send_channel_close(self->a_conn, 0);
+ } else {
+ send_connection_close(self->a_conn);
+ }
+ }
+ /* Release the lock */
+ pthread_mutex_unlock(&self->send_mutex);
+
+ /* Now wvait for the thread to stop */
+ pthread_join(self->thread, &ret);
+}
+
+/*
+ * Report general error
+ */
+static int manage_error(int x, char const *context)
+{
+ int retVal = 0; // false
+
+ if (x < 0) {
+ #if (AMQP_VERSION_MINOR >= 4)
+ const char *errstr = amqp_error_string2(-x);
+ LogError(0, RS_RET_ERR, "omrabbitmq: %s: %s", context, errstr);
+ #else
+ char *errstr = amqp_error_string(-x);
+ LogError(0, RS_RET_ERR, "omrabbitmq: %s: %s", context, errstr);
+ free(errstr);
+ #endif
+ retVal = 1; // true
+ }
+
+ return retVal;
+}
+
+static rsRetVal publishRabbitMQ(wrkrInstanceData_t *self, amqp_bytes_t exchange,
+ amqp_bytes_t routing_key, amqp_basic_properties_t *p_amqp_props,
+ amqp_bytes_t body_bytes)
+{
+ DEFiRet;
+ /* locks to allow exclusive access to connection */
+ if (mode_test > 0) {
+ struct timeval tv;
+ tv.tv_sec = mode_test/1000;
+ tv.tv_usec = mode_test%1000 * 1000;
+ select(0, NULL, NULL, NULL, &tv);
+ }
+
+ pthread_mutex_lock(&self->send_mutex);
+
+ if (self->state != RS_RET_OK)
+ ABORT_FINALIZE(self->state);
+
+ if (!self->a_conn){
+ ABORT_FINALIZE(RS_RET_RABBITMQ_CONN_ERR);
+ }
+
+ if (manage_error(amqp_basic_publish(self->a_conn, 1, exchange, routing_key,
+ 0, 0, p_amqp_props, body_bytes), "amqp_basic_publish")) {
+ /* error already notified */
+ FINALIZE;
+ }
+
+finalize_it:
+ /* release exclusive access to connection */
+ pthread_mutex_unlock(&self->send_mutex);
+ RETiRet;
+}
+
+BEGINdoAction
+ int iLen;
+CODESTARTdoAction
+ /* The first element is a smsg_t pointer */
+ smsg_t **pMsg = (smsg_t **)pMsgData;
+ smsg_t *msg = pMsg[0];
+
+ amqp_bytes_t body_bytes;
+ amqp_basic_properties_t *amqp_props_msg;
+
+ if (!pWrkrData->pData->idx_body_template)
+ {
+ /* No body template so send it as rawmsg */
+ getRawMsg(msg, (uchar**)(&body_bytes.bytes), &iLen);
+ body_bytes.len = (size_t)iLen;
+ amqp_props_msg = &pWrkrData->pData->amqp_props_plaintext;
+ }
+ else
+ {
+ /* we have a body template */
+ body_bytes = cstring_bytes((char*)ppString[pWrkrData->pData->idx_body_template]);
+ amqp_props_msg = &pWrkrData->pData->amqp_props_tpl_type;
+ }
+
+ if (pWrkrData->pData->populate_properties) {
+ /* populate amqp message properties */
+ msgPropDescr_t pProp;
+ int i, custom = 0;
+ amqp_basic_properties_t amqp_props;
+
+ memcpy(&amqp_props, amqp_props_msg, sizeof(amqp_basic_properties_t));
+
+ /* list and mapping of smsg to amqp properties */
+ msg2amqp_props_t prop_list[] = {
+ { PROP_SYSLOGFACILITY_TEXT, "facility", NULL, 0 },
+ { PROP_SYSLOGSEVERITY_TEXT, "severity", NULL, 0 },
+ { PROP_HOSTNAME, "hostname", NULL, 0 },
+ { PROP_FROMHOST, "fromhost", NULL, 0 },
+ { PROP_SYSLOGTAG, NULL, &(amqp_props.app_id), AMQP_BASIC_APP_ID_FLAG }
+ };
+ int len = sizeof(prop_list)/sizeof(msg2amqp_props_t);
+ uchar *val[sizeof(prop_list)/sizeof(msg2amqp_props_t)];
+ rs_size_t valLen[sizeof(prop_list)/sizeof(msg2amqp_props_t)];
+ unsigned short mustBeFreed[sizeof(prop_list)/sizeof(msg2amqp_props_t)];
+ struct amqp_table_entry_t_ tab_entries[sizeof(prop_list)/sizeof(msg2amqp_props_t)];
+
+ amqp_props.headers.entries = tab_entries;
+
+ amqp_props.timestamp = (uint64_t)datetime.syslogTime2time_t(&msg->tTIMESTAMP);
+ amqp_props._flags |= AMQP_BASIC_TIMESTAMP_FLAG;
+
+ for (i=0; i<len; i++)
+ {
+ /* for each msg property in list get the value and initialize flags */
+ pProp.id = prop_list[i].id;
+ valLen[i] = 0;
+ mustBeFreed[i] = 0;
+ val[i] = (uchar*)MsgGetProp(msg, NULL, &pProp, &(valLen[i]), &(mustBeFreed[i]), NULL);
+ if (val[i] && *val[i])
+ {
+ if (prop_list[i].name)
+ {
+ /* custom amqp properties */
+ tab_entries[custom].key = amqp_cstring_bytes(prop_list[i].name);
+ tab_entries[custom].value.kind = AMQP_FIELD_KIND_UTF8;
+ tab_entries[custom].value.value.bytes = amqp_cstring_bytes((char*)val[i]);
+ amqp_props._flags |= AMQP_BASIC_HEADERS_FLAG;
+ custom++;
+ } else {
+ /* standard amqp properties*/
+ prop_list[i].standardprop->bytes = val[i];
+ prop_list[i].standardprop->len = (size_t)valLen[i];
+ amqp_props._flags |= prop_list[i].flag;
+ }
+ }
+ }
+ amqp_props.headers.num_entries = custom;
+
+ /* CHKiRet could not be used because we need to release allocations */
+ iRet = publishRabbitMQ(pWrkrData, pWrkrData->pData->exchange,
+ (pWrkrData->pData->routing_key_template)?
+ cstring_bytes((char*)ppString[pWrkrData->pData->idx_routing_key_template])
+ : pWrkrData->pData->routing_key,
+ &amqp_props, body_bytes);
+
+ for (i=0; i<len; i++)
+ if (mustBeFreed[i]) free(val[i]);
+ }
+ else
+ {
+ /* As CHKiRet could not be used earlier, iRet is directly used again */
+ iRet = publishRabbitMQ(pWrkrData, pWrkrData->pData->exchange,
+ (pWrkrData->pData->routing_key_template)?
+ cstring_bytes((char*)ppString[pWrkrData->pData->idx_routing_key_template])
+ : pWrkrData->pData->routing_key,
+ amqp_props_msg, body_bytes);
+ }
+
+ENDdoAction
+
+BEGINtryResume
+CODESTARTtryResume
+ iRet = startAMQPConnection(pWrkrData);
+ENDtryResume
+
+BEGINcreateInstance
+ void *env_var;
+CODESTARTcreateInstance
+ if ((env_var = getenv("OMRABBITMQ_TEST")) != NULL)
+ mode_test = atoi(env_var);
+
+ memset(pData, 0, sizeof(instanceData));
+ pData->iidx = ++instance_counter;
+ pData->delivery_mode = 2;
+ pData->exchange_type = NULL;
+ pData->durable = 0;
+ pData->auto_delete = 1;
+ pData->ssl = 0;
+ pData->initOpenSSL = 0;
+ pData->verifyPeer = 0;
+ pData->verifyHostname = 0;
+ pData->caCert = NULL;
+ pData->heartbeat = 0;
+ENDcreateInstance
+
+BEGINfreeInstance
+CODESTARTfreeInstance
+ /* this is a cleanup callback. All dynamically-allocated resources
+ * in instance data must be cleaned up here. Prime examples are
+ * malloc()ed memory, file & database handles and the like.
+ */
+ if (pData->exchange.bytes) free(pData->exchange.bytes);
+ if (pData->routing_key.bytes) free(pData->routing_key.bytes);
+ if (pData->routing_key_template) free(pData->routing_key_template);
+ if (pData->body_template) free(pData->body_template);
+ if (pData->expiration.bytes) free(pData->expiration.bytes);
+ if (pData->content_type) free(pData->content_type);
+ if (pData->vhost) free(pData->vhost);
+ if (pData->user) free(pData->user);
+ if (pData->password) free(pData->password);
+ if (pData->exchange_type) free(pData->exchange_type);
+ if (pData->server1.host) free(pData->server1.host);
+ if (pData->caCert) free(pData->caCert);
+ENDfreeInstance
+
+BEGINisCompatibleWithFeature
+CODESTARTisCompatibleWithFeature
+ /* use this to specify if select features are supported by this
+ * plugin. If not, the framework will handle that. Currently, only
+ * RepeatedMsgReduction ("last message repeated n times") is optional.
+ */
+ if(eFeat == sFEATURERepeatedMsgReduction)
+ iRet = RS_RET_OK;
+ENDisCompatibleWithFeature
+
+BEGINdbgPrintInstInfo
+CODESTARTdbgPrintInstInfo
+ /* permits to spit out some debug info */
+ dbgprintf("omrabbitmq instance : %d\n", pData->iidx);
+ if (pData->server2.host) {
+ dbgprintf("\thost1='%s' \n", pData->server1.host);
+ dbgprintf("\tport1=%d\n", pData->server1.port);
+ dbgprintf("\thost2='%s' \n", pData->server2.host);
+ dbgprintf("\tport2=%d\n", pData->server2.port);
+ dbgprintf("\tfailback policy :");
+ dbgprintf("\t\tusual server check interval=%ld s",
+ pData->recover_policy.return_check_interval);
+ dbgprintf("\t\tquick oscillation limit=%ld s",
+ pData->recover_policy.quick_oscillation_interval);
+ dbgprintf("\t\tmax number of oscillation=%d s",
+ pData->recover_policy.quick_oscillation_max);
+ dbgprintf("\t\tgraceful interval after quick oscillation detection=%ld s",
+ pData->recover_policy.graceful_interval);
+ }else{
+ dbgprintf("\thost='%s' \n", pData->server1.host);
+ dbgprintf("\tport=%d\n", pData->server1.port);
+ }
+ dbgprintf("\tvirtual_host='%s'\n", pData->vhost);
+ dbgprintf("\tuser='%s'\n", pData->user == NULL ? "(not configured)" : pData->user);
+ dbgprintf("\tpassword=(%sconfigured)\n", pData->password == NULL ? "not " : "");
+ dbgprintf("\tssl=%d\n", pData->ssl);
+ dbgprintf("\tinit_openssl=%d\n", pData->initOpenSSL);
+ dbgprintf("\tverify_peer=%d\n", pData->verifyPeer);
+ dbgprintf("\tverify_hostname=%d\n", pData->verifyHostname);
+ dbgprintf("\tca_cert='%s'\n", pData->caCert);
+ dbgprintf("\theartbeat_interval=%d\n", pData->heartbeat);
+
+ dbgprintf("\texchange='%*s'\n", (int)pData->exchange.len,
+ (char*)pData->exchange.bytes);
+ dbgprintf("\trouting_key='%*s'\n", (int)pData->routing_key.len,
+ (char*) pData->routing_key.bytes);
+ dbgprintf("\trouting_key_template='%s'\n", pData->routing_key_template);
+ dbgprintf("\tbody_template='%s'\n", pData->body_template);
+ dbgprintf("\texchange_type='%s'\n", pData->exchange_type);
+ dbgprintf("\tauto_delete=%d\n", pData->auto_delete);
+ dbgprintf("\tdurable=%d\n", pData->durable);
+ dbgprintf("\tpopulate_properties=%s\n", (pData->populate_properties)?"ON":"OFF");
+ dbgprintf((pData->delivery_mode == 1) ? "\tdelivery_mode=TRANSIENT\n":
+ "\tdelivery_mode=PERSISTENT\n");
+ if (pData->expiration.len == 0) {
+ dbgprintf("\texpiration=UNLIMITED\n");
+ }else{
+ dbgprintf("\texpiration=%*s\n",
+ (int)pData->expiration.len, (char*) pData->expiration.bytes);
+ }
+ENDdbgPrintInstInfo
+
+BEGINnewActInst
+ struct cnfparamvals *pvals;
+ int i;
+ char *host = NULL, *vhost= NULL, *user = NULL, *password = NULL, *recover = NULL;
+ int port = 0;
+ long long expiration = 0;
+CODESTARTnewActInst
+
+ if((pvals = nvlstGetParams(lst, &actpblk, NULL)) == NULL) {
+ ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS);
+ }
+
+ CHKiRet(createInstance(&pData));
+
+ /* let read parameters */
+ for(i = 0 ; i < actpblk.nParams ; ++i) {
+ if (!pvals[i].bUsed)
+ continue;
+ if (!strcmp(actpblk.descr[i].name, "host")) {
+ host = (char*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "recover_policy")) {
+ recover = es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "port")) {
+ port = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "virtual_host")) {
+ vhost = (char*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "user")) {
+ user = (char*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "password")) {
+ password = (char*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "ssl")) {
+ pData->ssl = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "ca_cert")) {
+ pData->caCert = (char*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "heartbeat_interval")) {
+ pData->heartbeat = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "init_openssl")) {
+ pData->initOpenSSL = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "verify_peer")) {
+ pData->verifyPeer = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "verify_hostname")) {
+ pData->verifyHostname = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "exchange")) {
+ pData->exchange = cstring_bytes(es_str2cstr(pvals[i].val.d.estr, NULL));
+ } else if (!strcmp(actpblk.descr[i].name, "routing_key")) {
+ pData->routing_key = cstring_bytes(es_str2cstr(pvals[i].val.d.estr, NULL));
+ } else if (!strcmp(actpblk.descr[i].name, "routing_key_template")) {
+ pData->routing_key_template = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "populate_properties")) {
+ pData->populate_properties = (sbool) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "delivery_mode")) {
+ char *temp = (char*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ if (temp){
+ if (!strcasecmp(temp, "TRANSIENT") || !strcmp(temp, "1")) {
+ pData->delivery_mode = 1;
+ } else { if (!strcasecmp(temp, "PERSISTENT") || !strcmp(temp, "2")) {
+ pData->delivery_mode = 2;
+ } else {
+ pData->delivery_mode = 0;
+ } }
+ free(temp);
+ }
+ } else if (!strcmp(actpblk.descr[i].name, "expiration")) {
+ expiration = pvals[i].val.d.n;
+ if (expiration > 0) {
+ char buf[40];
+ snprintf(buf, 40, "%lld", expiration);
+ #ifndef __clang_analyzer__
+ pData->expiration = cstring_bytes(strdup(buf));
+ #endif
+ }
+ } else if (!strcmp(actpblk.descr[i].name, "body_template")) {
+ pData->body_template = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "content_type")) {
+ pData->content_type = es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "exchange_type")) {
+ pData->exchange_type = es_str2cstr(pvals[i].val.d.estr, NULL);
+ } else if (!strcmp(actpblk.descr[i].name, "auto_delete")) {
+ pData->auto_delete = (int) pvals[i].val.d.n;
+ } else if (!strcmp(actpblk.descr[i].name, "durable")) {
+ pData->durable = (int) pvals[i].val.d.n;
+ } else {
+ LogError(0, RS_RET_INVALID_PARAMS,
+ "omrabbitmq module %d: program error, non-handled param '%s'\n",
+ pData->iidx, actpblk.descr[i].name);
+ }
+ }
+
+ /* let's check config validity */
+
+ if (host == NULL) {
+ LogError(0, RS_RET_INVALID_PARAMS, "omrabbitmq module %d disabled: parameter "
+ "host must be specified",
+ pData->iidx);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
+ }
+
+ /* first if a template for routing_key is set let verify its existence */
+ if (pData->routing_key_template && tplFind(ourConf, (char*)pData->routing_key_template,
+ strlen((char*)pData->routing_key_template)) == NULL)
+ {
+ LogError(0, RS_RET_INVALID_PARAMS, "omrabbitmq module %d : template '%s'"
+ " used for routing key does not exist !",
+ pData->iidx, pData->routing_key_template);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
+ }
+
+ /* an exchange must be defined */
+ if (pData->exchange.bytes == NULL) {
+ LogError(0, RS_RET_INVALID_PARAMS, "omrabbitmq module %d disabled: parameter "
+ "exchange must be specified",
+ pData->iidx);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
+ }
+
+ /* a static or a template's routing_key must be defined */
+ if (pData->routing_key.bytes == NULL && pData->routing_key_template == NULL) {
+ LogError(0, RS_RET_INVALID_PARAMS, "omrabbitmq module %d disabled: "
+ "one of parameters routing_key or "
+ "routing_key_template must be specified", pData->iidx);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
+ }
+
+ /* a valid delivery mode must be defined : a 0 means that an invalid value
+ * has been done */
+ if (!pData->delivery_mode)
+ {
+ LogError(0, RS_RET_CONF_PARAM_INVLD, "omrabbitmq module %d disabled: "
+ "parameter delivery_mode must be "
+ "TRANSIENT or PERSISTENT (default)", pData->iidx);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
+ }
+
+ /* first if a template for message body is set let verify its existence */
+ if (pData->body_template && *pData->body_template &&
+ tplFind(ourConf, (char*)pData->body_template,
+ strlen((char*)pData->body_template)) == NULL)
+ {
+ LogError(0, RS_RET_CONF_PARAM_INVLD, "omrabbitmq module %d : template '%s'"
+ " used for body does not exist !",
+ pData->iidx, pData->body_template);
+ ABORT_FINALIZE(RS_RET_CONFIG_ERROR);
+ }
+
+ /* Let's define the size of the doAction tab */
+ CODE_STD_STRING_REQUESTnewActInst(1 + ((pData->routing_key_template) ? 1 : 0) +
+ ((pData->body_template && *pData->body_template == '\0') ? 0 : 1));
+
+ /* Set the plain text message props */
+ memset(&pData->amqp_props_plaintext, 0, sizeof(amqp_basic_properties_t));
+ pData->amqp_props_plaintext._flags =
+ AMQP_BASIC_DELIVERY_MODE_FLAG | AMQP_BASIC_CONTENT_TYPE_FLAG;
+ pData->amqp_props_plaintext.delivery_mode = pData->delivery_mode;
+ /* persistent delivery mode */
+ pData->amqp_props_plaintext.content_type = amqp_cstring_bytes("plain/text");
+ if (pData->expiration.len)
+ {
+ pData->amqp_props_plaintext._flags |= AMQP_BASIC_EXPIRATION_FLAG;
+ pData->amqp_props_plaintext.expiration = pData->expiration;
+ }
+
+ memcpy(&pData->amqp_props_tpl_type, &pData->amqp_props_plaintext,
+ sizeof(amqp_basic_properties_t));
+
+ /* The first position of doAction tab will contain the internal message */
+ CHKiRet(OMSRsetEntry(*ppOMSR, 0, NULL, OMSR_TPL_AS_MSG));
+
+ // RabbitMQ properties initialization
+ if (pData->routing_key_template)
+ {
+ pData->idx_routing_key_template = 1;
+ CHKiRet(OMSRsetEntry(*ppOMSR, 1,
+ (uchar*)strdup((const char *)pData->routing_key_template),
+ OMSR_NO_RQD_TPL_OPTS));
+ }
+
+ /* if pData->body_template is NULL (not defined) then let's use former
+ * json format if pData->body_template is not an empty string then let's
+ * use it. In this case the content type is defined either
+ * by the template name or the user defined content_type if set
+ * otherwise raw data (unformatted) are sent this is done setting
+ * pData->idx_body_template to 0 */
+ if (pData->body_template == NULL)
+ { /* no template */
+ DBGPRINTF("Body_template is using default StdJSONFmt definition.\n");
+ pData->idx_body_template = pData->idx_routing_key_template + 1;
+ CHKiRet(OMSRsetEntry(*ppOMSR, pData->idx_body_template,
+ (uchar*)strdup(" StdJSONFmt"), OMSR_NO_RQD_TPL_OPTS));
+ pData->amqp_props_tpl_type.content_type = amqp_cstring_bytes("application/json");
+ }
+ else if (*pData->body_template)
+ {
+ pData->idx_body_template = pData->idx_routing_key_template + 1;
+ CHKiRet(OMSRsetEntry(*ppOMSR, pData->idx_body_template,
+ (uchar*)strdup((const char *)pData->body_template),
+ OMSR_NO_RQD_TPL_OPTS));
+ pData->amqp_props_tpl_type.content_type = amqp_cstring_bytes(
+ (pData->content_type)
+ ? pData->content_type
+ : (char*)pData->body_template);
+ }else{
+ pData->idx_body_template = 0;
+ pData->amqp_props_tpl_type.content_type = amqp_cstring_bytes(
+ (pData->content_type)
+ ? pData->content_type
+ :"raw");
+ }
+
+ /* treatment of the server parameter
+ * first the default port */
+ pData->server2.port = pData->server1.port = port ? port : 5672;
+
+ char *temp;
+ int p;
+ pData->server1.host = host;
+
+ /* Is there more than one server in parameter */
+ if ((pData->server2.host = strchr(pData->server1.host,' ')) != NULL)
+ {
+ *pData->server2.host++ ='\0';
+ /* is there a port with the second server */
+ if ((temp = strchr(pData->server2.host,':')) != NULL)
+ {
+ *temp++ ='\0';
+ p = atoi(temp);
+ if (p) pData->server2.port = p;
+ }
+ }
+
+ /* is there a port with the first/unique server */
+ if ((temp = strchr(pData->server1.host,':')) != NULL)
+ {
+ *temp++ ='\0';
+ p = atoi(temp);
+ if (p) pData->server1.port = p;
+ }
+
+ pData->vhost = vhost ? vhost : strdup("/");
+ pData->user = user ? user : strdup("");
+ pData->password = password ? password : strdup("");
+
+ init_recover(&pData->recover_policy, recover);
+
+ if (recover)
+ free(recover);
+
+ dbgPrintInstInfo(pData);
+
+CODE_STD_FINALIZERnewActInst
+ cnfparamvalsDestruct(pvals, &actpblk);
+ENDnewActInst
+
+
+NO_LEGACY_CONF_parseSelectorAct
+
+
+BEGINmodExit
+CODESTARTmodExit
+ objRelease(glbl, CORE_COMPONENT);
+ objRelease(datetime, CORE_COMPONENT);
+ENDmodExit
+
+BEGINcreateWrkrInstance
+CODESTARTcreateWrkrInstance
+ memset(pWrkrData, 0, sizeof(wrkrInstanceData_t));
+
+ pWrkrData->pData = pData;
+
+ pthread_mutex_init(&pWrkrData->send_mutex, NULL);
+ pthread_cond_init(&pWrkrData->cond, NULL);
+
+ pWrkrData->state = RS_RET_SUSPENDED;
+ pWrkrData->iidx = pData->iidx;
+ pWrkrData->widx = ++pData->nbWrkr;
+
+ memcpy(&(pWrkrData->recover_policy), &(pData->recover_policy),
+ sizeof(recover_t));
+
+ if (pData->server2.host && *pData->server2.host) {
+ time_t odd = time(NULL) % 2;
+ memcpy(&(pWrkrData->serverPrefered.s), (odd) ?
+ &pData->server1 : &pData->server2, sizeof(server_t));
+ memcpy(&(pWrkrData->serverBackup.s), (odd) ?
+ &pData->server2 : &pData->server1, sizeof(server_t));
+ }else{
+ memcpy(&(pWrkrData->serverPrefered.s), &pData->server1, sizeof(server_t));
+ }
+ pWrkrData->serverActive = &pWrkrData->serverPrefered;
+
+ startAMQPConnection(pWrkrData);
+
+ENDcreateWrkrInstance
+
+BEGINfreeWrkrInstance
+CODESTARTfreeWrkrInstance
+
+ if (pWrkrData != NULL) {
+ closeAMQPConnection(pWrkrData);
+
+ pthread_mutex_destroy(&(pWrkrData->send_mutex));
+ pthread_cond_destroy(&(pWrkrData->cond));
+ }
+ENDfreeWrkrInstance
+
+BEGINqueryEtryPt
+CODESTARTqueryEtryPt
+ CODEqueryEtryPt_STD_OMOD_QUERIES
+ CODEqueryEtryPt_STD_OMOD8_QUERIES
+ CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES
+ENDqueryEtryPt
+
+BEGINmodInit()
+CODESTARTmodInit
+ *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
+CODEmodInit_QueryRegCFSLineHdlr
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
+ CHKiRet(objUse(datetime, CORE_COMPONENT));
+ENDmodInit