reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
queuetostream.cpp
Go to the documentation of this file.
1#include <signal.h>
2
3// Need to include this early to avoid problems with __STDC_FORMAT_MACROS
4#include "rutil/compat.hxx"
5
7#include <rutil/Time.hxx>
8#include <rutil/Logger.hxx>
10
11using namespace resip;
12using namespace std;
13using namespace repro;
14
15static bool finished = false;
16
17static void
18signalHandler(int signo)
19{
20 std::cerr << "Shutting down" << endl;
21 finished = true;
22}
23
24int
25main (int argc, char** argv)
26{
27 // Install signal handlers
28#ifndef _WIN32
29 if ( signal( SIGPIPE, SIG_IGN) == SIG_ERR)
30 {
31 cerr << "Couldn't install signal handler for SIGPIPE" << endl;
32 exit(-1);
33 }
34#endif
35
36 if ( signal( SIGINT, signalHandler ) == SIG_ERR )
37 {
38 cerr << "Couldn't install signal handler for SIGINT" << endl;
39 exit( -1 );
40 }
41
42 if ( signal( SIGTERM, signalHandler ) == SIG_ERR )
43 {
44 cerr << "Couldn't install signal handler for SIGTERM" << endl;
45 exit( -1 );
46 }
47
48 // Log any resip logs to cerr, since session events are logged to cout
50
51 Data msgQueueName("sessioneventqueue");
52 if(argc >= 2)
53 {
54 msgQueueName = argv[1];
55 }
57 if(queue->init(true, msgQueueName))
58 {
59 vector<resip::Data> recs;
60 while(!finished)
61 {
62 if(queue->pop(5, recs, true))
63 {
64 if(recs.size() > 0)
65 {
66 for(size_t i = 0; i < recs.size(); i++)
67 {
68 cout << recs[i] << endl;
69 }
70 }
71 else
72 {
74 }
75 }
76 else
77 {
78 if(queue->isRecoveryNeeded())
79 {
80 delete queue;
81 queue = new PersistentMessageDequeue("");
82 if(!queue->init(true, msgQueueName))
83 {
84 cerr << "Error initializing message queue after error!" << endl;
85 break;
86 }
87 }
88 else
89 {
90 cerr << "Error dequeuing!" << endl;
91 break;
92 }
93 }
94 }
95 }
96 else
97 {
98 cerr << "Error initializing message queue!" << endl;
99 }
100 delete queue;
101}
102
103
104/* ====================================================================
105 * The Vovida Software License, Version 1.0
106 *
107 * Copyright (c) 2000-2012
108 *
109 * Redistribution and use in source and binary forms, with or without
110 * modification, are permitted provided that the following conditions
111 * are met:
112 *
113 * 1. Redistributions of source code must retain the above copyright
114 * notice, this list of conditions and the following disclaimer.
115 *
116 * 2. Redistributions in binary form must reproduce the above copyright
117 * notice, this list of conditions and the following disclaimer in
118 * the documentation and/or other materials provided with the
119 * distribution.
120 *
121 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
122 * and "Vovida Open Communication Application Library (VOCAL)" must
123 * not be used to endorse or promote products derived from this
124 * software without prior written permission. For written
125 * permission, please contact vocal@vovida.org.
126 *
127 * 4. Products derived from this software may not be called "VOCAL", nor
128 * may "VOCAL" appear in their name, without prior written
129 * permission of Vovida Networks, Inc.
130 *
131 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
132 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
133 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
134 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
135 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
136 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
137 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
138 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
139 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
140 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
141 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
142 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
143 * DAMAGE.
144 *
145 * ====================================================================
146 *
147 * This software consists of voluntary contributions made by Vovida
148 * Networks, Inc. and many individuals on behalf of Vovida Networks,
149 * Inc. For more information on Vovida Networks, Inc., please see
150 * <http://www.vovida.org/>.
151 *
152 */
153/*
154 * vi: set shiftwidth=3 expandtab:
155 */
bool pop(size_t numRecords, std::vector< resip::Data > &records, bool autoCommit)
bool init(bool sync, const resip::Data &queueName)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static void initialize(Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0, const Data &syslogFacility="LOG_DAEMON", MessageStructure messageStructure=Unstructured, const Data &instanceName="")
Definition Log.cxx:268
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
void sleepSeconds(unsigned int seconds)
Definition Time.cxx:28
int main(int argc, char **argv)
static void signalHandler(int signo)
static bool finished