Commit Graph

400 Commits

Author SHA1 Message Date
Emiel Bruijntjes d3c0ea293b better error message if channel is in an error state 2017-03-02 12:09:08 +01:00
Emiel Bruijntjes ed2ffd3f03 added method tcpconnection::flush() 2016-09-19 10:19:06 +02:00
Emiel Bruijntjes 5bb7b1a36f added const char * constructors to AMQP::Login class 2016-09-15 12:53:55 +02:00
Emiel Bruijntjes 173225071e we no longer use "emit" for method names, because it seems to conflict with the Qt library that uses emit as some sort of macro 2016-09-10 20:36:06 +02:00
Martijn Otto afb04a8f30 Re-introduced the casting operators with a note explaining why we need this. 2016-09-05 10:11:31 +02:00
theirix c6643062b6 Removed unneeded self-cast operators
They are not used and caused a lot of warnings
while compiling and using AMQP-CPP
2016-09-02 22:33:12 +03:00
Emiel Bruijntjes 383914c0c7 Merge pull request #80 from theirix/sigpipe-osx
Avoid SIGPIPE on OS X without MSG_NOSIGNAL
2016-07-27 05:09:44 -04:00
Martijn Otto 53dd7c74c5 Merge pull request #86 from ogapo/master
libuv drop in implementation for TcpHandler
2016-07-18 15:12:24 +02:00
David Nikdel fd69a4c01d map closed sockets to both read and write
- this is more consistent with libev so probably will match what existing code expects
2016-07-16 20:43:19 -04:00
David Nikdel 584d92e751 can't use struct elaboration with typedef 2016-07-16 20:30:03 -04:00
David Nikdel 1e1ec0c133 Update libuv.h
- if status is not ok, report that as readable
- no need to stop uv_poll_t before changing events according to the docs
2016-07-16 20:27:00 -04:00
javeme 4b7874c5b6 Implement copy constructor for class Monitor
To support the instance copy of Monitor like the following:
    AMQP::Monitor monitor(consumer);
    consumer->bindExchange(exchange, AMQP::direct).onSuccess([&, monitor](){
        // do something when the consumer is ready!
        if(monitor.valid())
            consumer->doSomething();
    });
2016-07-17 00:54:42 +08:00
David Nikdel b8d2c0c600 fix casting 2016-07-14 23:49:31 -04:00
David Nikdel 5042b699bd create libuv.h based on libev.h 2016-07-14 23:30:43 -04:00
theirix 66f2001c7b Avoid SIGPIPE on OS X without MSG_NOSIGNAL
OS X does not have Linux-specific option MSG_NOSIGNAL.
SIGPIPE can be avoided on OS X by using sockopt SO_NOSIGPIPE.
Credits: https://noahdesu.github.io/2014/01/16/port-sendmsg.html
2016-07-10 21:44:14 +03:00
David van Erkelens dddd16b74d Make sure single gets are processed correctly as well 2016-07-05 16:39:12 +02:00
Martijn Otto 5d741bfd2d Merge branch 'master' of github.com:CopernicaMarketingSoftware/AMQP-CPP 2016-07-04 10:14:00 +02:00
Martijn Otto 5b40c04f2a Added documentation about missing RabbitMQ functionality 2016-07-04 10:13:50 +02:00
Martijn Otto c055b1a439 Merge pull request #77 from javeme/return-type-of-waiting
Correct the returning type of Connection::waiting()
2016-07-04 09:41:54 +02:00
javeme 5cff314d88 Correct the returning type of Connection::waiting()
The returning type of Connection::waiting() should be bool,
but currently it's size_t type.
2016-07-03 21:35:44 +08:00
Maksim Kuzevanov 1dcbc33b53 make it compile with cmake 2.8/gcc 4.7.3 2016-07-01 17:29:35 +03:00
Martijn Otto b91e0589f6 Updated cmake lists and added include, closes issue #75 2016-06-28 14:14:07 +02:00
Martijn Otto 2f1851728c Merge pull request #72 from XeCycle/fionread-solaris
Some portability fixes for Solaris-like systems
2016-06-27 10:57:24 +02:00
Martijn Otto d911d71dfa Removed the ugly typedef 2016-06-27 10:52:58 +02:00
javeme 5c3ba7b00a Program crashes when receiving a message due to memory corruption
crashes due to the wrong way using aligned_storage.

Steps to reproduce:
1. Start a consumer
  channel.consume(queue, tag).onMessage(msgCallback)
2. Send a message to the consumer
3. The program crashes

Environment:
Windows 7 / VS2010

The reason:
The Windows prompted to memory corruption, I found some strange phenomenon
about stack_ptr<Message>, such as:
  1.sizeof(stack_ptr<Message>) is equal to 2
  2.stack_ptr._initialized becomes true after construct() called (actually,
    it never has been assigned true, please see [1])

Finally I found that the root cause was stack_ptr._data, we directly used
aligned_storage rather than aligned_storage::type[2] as the type of _data.
so the _data was just an empty struct, and subsequent operations were
performed in illegal memory. It eventually led to the crash.

This patch we fixed the bug and add "_initialized = true" at the end of the
method stack_ptr::construct().

[1] https://github.com/CopernicaMarketingSoftware/AMQP-CPP/blob/master/include/stack_ptr.h#L83
[2] http://www.cplusplus.com/reference/type_traits/aligned_storage/
2016-06-27 02:03:15 +08:00
Carl Lei 55aba43078 portability fix for pow overload resolution
On Solaris the compiler is missing the template overload.
2016-06-25 20:15:44 +08:00
Martijn Otto ba6b3e2923 Copied the methods to both implementations so they can return their concrete type 2016-06-23 16:02:04 +02:00
Martijn Otto 2c60151d31 Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
Emiel Bruijntjes 24c8527b5d added tcpinbuffer with much less allocation 2016-06-15 13:32:30 -04:00
Emiel Bruijntjes 6320e2ae0e added consistent-hash exchange (same as pull request #68) 2016-06-15 11:20:31 -04:00
Emiel Bruijntjes 59830c659c added connection::maxFrame() and connection::expected() methods to give hints about the amount of data that the connection::parse() method ideally expects 2016-06-15 04:57:46 -04:00
Jan Westerdiep 7384b521ac small legibility fixes 2016-06-10 15:21:10 +02:00
hoxnox 15fa529bfd Bugfix: add missing include guards 2016-04-06 17:49:39 +03:00
Aljar Meesters 70a7565c4e fixed bug when connection goes out of scope 2016-03-04 17:34:28 +01:00
Martijn Otto 89c2075a5f Fix segfault when the handler is destructed from within a callback 2016-01-15 14:19:09 +01:00
Brent Dimmig bbfcf76f39 add TcpHandler implementation for libevent 2016-01-09 16:03:42 -05:00
Martijn Otto 18bf111eec fixed changing io events for libev 2016-01-04 16:53:22 +01:00
Toon Schoenmakers 09ad7b6cf4 How about we include libev before using the structs from libev? 2015-12-30 16:04:34 +01:00
Toon Schoenmakers 93a0b60b6e clients can now intercept the heartbeat negotiation, and install a shorter of longer heartbeat interval, and clients can be notified for received heartbeat frames 2015-12-02 10:46:55 +01:00
Emiel Bruijntjes 57c1109115 added extra Table::set() methods 2015-11-28 17:30:02 +01:00
Emiel Bruijntjes 155c989db5 added "override" keywords to overridden methods, fixed buffer overflow in setting up a connection 2015-11-28 11:38:15 +01:00
Emiel Bruijntjes 16a5104cd1 added include guard 2015-11-17 11:17:21 +01:00
Emiel Bruijntjes 3c6f909871 on second thought, should not be protected 2015-11-17 10:07:33 +01:00
Emiel Bruijntjes 1fc239f9fe loop member is now protected (could be useful) 2015-11-17 10:06:26 +01:00
Emiel Bruijntjes 66d2173f86 added libev implementation for the Tcp handler, added libev example program 2015-11-17 09:33:28 +01:00
Toon Schoenmakers c783ec7618 When building the address url, username and password should be split with a colon 2015-11-02 17:53:43 +01:00
Toon Schoenmakers 875300dbce Exposed the channels method in the TcpConnection class and added a more specialized constructor to the Address class 2015-11-02 17:47:21 +01:00
Emiel Bruijntjes b610ac5183 added TcpConnection::close() method 2015-11-01 12:20:12 +01:00
Emiel Bruijntjes 9e08c6932f extra Address constructor added 2015-11-01 12:17:33 +01:00
Emiel Bruijntjes 6061d853c7 Merge pull request #44 from Kojoley/envelope-copyctor-fix
AMQP::Envelope copy constructor missing base class constructor call
2015-11-01 05:14:27 -05:00
Emiel Bruijntjes 34699cfcd3 fixed formatting 2015-11-01 11:10:01 +01:00
Emiel Bruijntjes 0e5024d38a Merge pull request #47 from keenlogics/Heartbeat
The server heartbeat is stored in Connection
2015-11-01 05:03:02 -05:00
Emiel Bruijntjes 66ade94fc0 moved the #pragma once statement 2015-11-01 10:48:13 +01:00
Emiel Bruijntjes d41423d5db Added TcpChannel class so that Connection and Channel class are once again completely protocol agnostic 2015-11-01 09:51:43 +01:00
Emiel Bruijntjes b4bd61580b fixed to parsing incoming tcp data 2015-11-01 09:43:17 +01:00
Emiel Bruijntjes df801953a1 improvements to work directly with tcp connections 2015-10-31 21:13:41 +01:00
Emiel Bruijntjes 189d6c9ef1 added Connection::waiting() method to find out if the connection object is waiting/expecting an answer from the rabbitmq server 2015-10-31 18:26:52 +01:00
Emiel Bruijntjes f3955bcd51 implemented TcpConnection, so that users of the library do not have to setup their own tcp connections 2015-10-31 18:26:04 +01:00
Emiel Bruijntjes d18fd082d2 use move semantics in Login class (small optimization) 2015-10-31 18:23:24 +01:00
Emiel Bruijntjes fc5a053089 added "Address" class to parse "amqp://" urls 2015-10-31 18:22:41 +01:00
Sebastian Melinat 74a1a17553 During the handshake the heartbeat duration the server wants is stored in the connection so that clients can retrieve and use it for error detection 2015-10-21 15:26:53 +02:00
Nikita Kniazev ca522a32a5 AMQP::Envelope copy constructor missing base class constructor call 2015-09-28 12:56:52 +03:00
Toon Schoenmakers 12af6e854a Added a method to check how many channels a connection has 2015-09-10 14:33:25 +02:00
Toon Schoenmakers a0d7063c4e Fixed a few incorrect signatures in docblocks 2015-08-03 16:25:25 +02:00
Martijn Otto db3613112e Removed some macros for FreeBSD: Apparantly they are not needed. We might need to remove them for NetBSD and DragonFly as well 2015-07-01 09:48:56 +02:00
Martijn Otto 7a11c23f03 When a deferred handler is in error state, registering a finalize callback should also cause it to be called immediately 2015-06-12 16:48:25 +02:00
Martijn Otto a93b88697d Fix double ready bug for channel, fixes #25 2015-05-18 10:56:50 +02:00
Martijn Otto 7ae4f9c5ff Fixed a bug in the envelope, easy retrieval of field type and improved casting operators for numeric fields 2015-05-05 13:38:20 +02:00
Martijn Otto fcc9522e16 Some bugfixes and performance enhancements 2015-04-30 14:18:18 +02:00
Martijn Otto 45deeaa754 Fixed a bug where a frame could be sent exceeding the maximum frame size (resulting in protocol errors) and added some optimizations 2015-04-30 10:59:03 +02:00
Martijn Otto b9caf0199d Received messages are now moved into the callback instead of provided as a const reference 2015-04-28 10:58:49 +02:00
Emiel Bruijntjes ad3b95741e various trics and changes so that windows compilers, and 32bit systems will not complain about stuff 2015-04-24 10:46:44 +02:00
Martijn Otto 803ba6cc88 Added publish method with r-value std::string 2015-04-22 14:24:00 +02:00
Emiel Bruijntjes df6b8ae743 in reaction to pull request #21 the "const uint**_t" return values have been changed into "uint**_t" return values 2015-02-17 09:02:51 +01:00
Sebastian Melinat 09850e792f Bugfix: ConnectionImpl::reportError calls ChannelImpl::reportError of every channel. The channel then removes itselfs from the connection. That caused the for loop to run out of bounds. Fixed by switching to while 2015-01-28 11:47:03 +01:00
Emiel Bruijntjes f23dc72a4f Fixed documentation, removed references to the ChannelHandler - an object that is no longer supported by AMQP-CPP 2015-01-26 14:47:30 +01:00
Emiel Bruijntjes 236dd02b13 fixed theoretical issue when deferredGet onSize() methods destructs the underlying channel object 2014-09-02 11:18:11 +02:00
Emiel Bruijntjes 9653578d4a The Channel.get().onFinalize() function was called before the Channel.get().onSuccess() method, which is strange. This has been fixed. To fix this, we had to refactor the Deferred* into shared_ptrs 2014-09-02 10:32:55 +02:00
Emiel Bruijntjes 6cc25c4b27 removed operator= from channels and connections 2014-08-29 13:24:24 +02:00
Emiel Bruijntjes aceac8b677 the finalize callback is now called as part of the deferred object destructor, this ensures that the finalize callback will always be called 2014-08-29 13:18:08 +02:00
Emiel Bruijntjes d35dba71a1 disabled copy constructors for channel and connection objects, because the end-user is not supposed to copy them 2014-08-29 13:17:17 +02:00
Emiel Bruijntjes ebcdd71848 Added onSize() method to DeferredGet 2014-08-28 10:02:01 +02:00
Emiel Bruijntjes c7b3f71f14 the connection.close function was only waiting for synchronous calls to complete, async calls that were waiting (after a synchronous) were still discarded, this has been fixed 2014-08-20 13:40:29 +02:00
Emiel Bruijntjes d23e818f64 turns out that shared_from_this() can not be called from the constructor, so we made a special attach() function to postpone object initialization 2014-08-20 12:44:52 +02:00
Emiel Bruijntjes 6997a70cf1 when a connection was closed, the commands already given to the channels were sometimes by-passed by the closing channel. This has been fixed. Also solved the problem that calls executed on channel objects that fall out of scope were not always completed 2014-08-20 11:47:16 +02:00
Michael van der Werve 170ef1f82a when a channel is destructed during a success-callback, the program crashed, this has been fixed by using shared_ptr 2014-08-19 17:43:12 +02:00
Michael van der Werve 07d9361d84 compile fixes 2014-08-19 15:00:20 +02:00
Michael van der Werve acda90655d login and vhost can now be fetched from the connection class 2014-08-19 14:54:30 +02:00
Emiel Bruijntjes 328820f898 renamed apple.h to endian.h because it turns out that it is also used for linux systems, and removed double implemented ChannelImpl::get() function 2014-08-14 15:25:44 +02:00
Emiel Bruijntjes 3e47191f90 fixed apple incompatibility 2014-08-14 15:19:08 +02:00
Emiel Bruijntjes 945a01f659 The Connection::parse() method can now also be called with a buffer object, which allows the user to implement the buffer much more efficiently: it no longer has to be an array 2014-08-13 13:01:27 +02:00
Richard Hodges d2a84b5f8d build - added new source files to CMakeLists 2014-08-07 11:09:02 +01:00
Emiel Bruijntjes 37a51cdc7b basic.get is asynchronous until the entire body has been received, only then subsequent messages are sent + first work in progress on implementing smarter buffers 2014-08-07 11:00:06 +01:00
Emiel Bruijntjes b4270f39bc added Channel::get() that allows one to retrieve a single message from the channel 2014-08-07 11:00:06 +01:00
Emiel Bruijntjes f905c9db49 Quality of service now supports "global" parameter (default is still false) 2014-08-07 11:00:05 +01:00
Emiel Bruijntjes e299aa5fac basic.get is asynchronous until the entire body has been received, only then subsequent messages are sent + first work in progress on implementing smarter buffers 2014-08-01 11:55:07 +02:00
Emiel Bruijntjes f39410039b added Channel::get() that allows one to retrieve a single message from the channel 2014-07-31 12:58:13 +02:00
Emiel Bruijntjes cac3247304 Quality of service now supports "global" parameter (default is still false) 2014-07-31 10:10:15 +02:00
Richard Hodges b9ca150dba merged from latest upstream 2014-07-28 15:16:32 +01:00
Richard Hodges b41e2edc52 Merge remote-tracking branch 'upstream/master' 2014-07-28 15:07:06 +01:00
Richard Hodges 7c0642f30d build - added CMakeLists.txt to allow integration into a CMAKE build tree 2014-07-11 18:17:03 +01:00
Martijn Otto ca8a39ea45 Fix memory leak 2014-05-06 16:49:43 +02:00
Martijn Otto a9570277b7 Removed the nowait option from the public interface, because the deferred would never be called and implemented a queue to wait for synchronous methods to complete before sending the next frame 2014-04-29 15:51:33 +02:00
Emiel Bruijntjes e0b709fa63 in case of a connection error, we no longer call the channel wide error handler 2014-04-16 12:04:44 +02:00
Emiel Bruijntjes e903cdb4ee the derived deferred classes now also re-implement the onSuccess() method to ensure that the same object type is returned, to support propert chaining 2014-04-16 11:43:27 +02:00
Emiel Bruijntjes 1fecc57d67 when a connection gets in error state, all deferred results will now also call their error callback, and the channel wide error handler is called _after_ all individual error handlers are called 2014-04-16 09:25:08 +02:00
Emiel Bruijntjes 59e0b61e6b installed test program, added onMessage() function in deferredconsumer 2014-04-15 14:49:03 +02:00
Emiel Bruijntjes 82249ee368 update documentation, error callbacks now get a const char * instead of a std::string 2014-04-15 14:22:30 +02:00
Emiel Bruijntjes 3d4a1b865e removed some @todo tags 2014-04-15 13:22:06 +02:00
Emiel Bruijntjes b13398b09d setTimeout function removed from connection handler, the finalize and error callbacks are called right away if installed on an object that already is in an error state 2014-04-15 13:18:32 +02:00
Emiel Bruijntjes 60b59524e7 when an error is detected on a channel, all subsequent and cached deferred objects are notified about the error too 2014-04-15 13:14:16 +02:00
Emiel Bruijntjes d08270701e refactored dealing with error messages 2014-04-15 13:01:27 +02:00
Emiel Bruijntjes ae7a32a8bf when a consumer is cancelled, it is also removed from the map of active consumers in the the ChannelImpl object 2014-04-15 12:36:11 +02:00
Emiel Bruijntjes 3b78247363 error callbacks get a const char *, no longer a std::string 2014-04-15 12:29:22 +02:00
Emiel Bruijntjes 301b8153e3 deferred objects are now correctly destructed + added extra checks so that no crashes occur when someone destructs a channel inside a callback function 2014-04-15 12:25:56 +02:00
Emiel Bruijntjes 745ab512a5 the consumer message callback can now also be installed via the Deferred objects, and it is no longer passed a consumer tag, because it already is obvious what the consumer tag is supposed to be 2014-04-15 11:39:52 +02:00
Emiel Bruijntjes 921f24ae06 de-templified the deferred objects, to make them easier to understand for other programmers 2014-04-15 10:43:33 +02:00
Emiel Bruijntjes 7b20f46519 removed channel parameter from the callbacks, because this can easily be captured 2014-04-15 08:52:49 +02:00
Emiel Bruijntjes b8d4581569 cast to array and cast to object implemented, refactored shared-ptr and clone() methods to utilize std::make_shared (see issue #7) 2014-04-14 17:14:36 +02:00
Emiel Bruijntjes bcc6eaff82 added const access for operator[] (issue #7) 2014-04-14 16:06:29 +02:00
Martijn Otto 83621790f4 Give the connection object to the timeout as well 2014-04-14 15:31:15 +02:00
Martijn Otto 05412e0d2b Merged recent commits 2014-04-14 14:23:37 +02:00
Martijn Otto f10e33c7c7 Fix logic error in the array type 2014-04-14 14:18:51 +02:00
Martijn Otto 1c0495378a Implemented deferred consumers and a setTimeout method on the connection handler for indicating immediate failures on deferred objects 2014-04-14 14:10:57 +02:00
Emiel Bruijntjes cf5def0e89 fixed operator[] for arrays and strings, implemented << operator for field and fieldproxy objects to simplify debugging (reported from issue #7) 2014-04-14 13:34:46 +02:00
Martijn Otto d2c17869e0 Moved the remaining methods over to deferred handlers 2014-04-10 12:51:04 +02:00
Martijn Otto e1b0e3dea1 Added a generic callback class that acts as a container for the different types of callbacks 2014-04-08 16:12:04 +02:00
Martijn Otto 2939272bc8 Work in progress to convert channel handler to callback system 2014-04-08 14:42:07 +02:00
Luca Marturana 17be969d49 Add pragma once 2014-04-02 15:40:35 +02:00
Luca Marturana 41c1402d15 Const modifier to table get and some array operations 2014-04-02 12:59:24 +02:00
Luca Marturana 47f5ec2710 On connection::parse char* can be const 2014-04-02 11:53:46 +02:00
Emiel Bruijntjes 6cfead9902 {auto} if connection.close() was called before the connection was set up, the instructions that were called between setting up the connection and the call to close() were lost. This forced users to always use the onConnected() handler to wait for the first instruction to be sent. But this is not according to the library design, so now the instructions that are given before the close() will be executed too; 2014-02-21 00:54:40 -08:00
Emiel Bruijntjes d4e543e74a Login object now has methods to retrieve user name and password 2014-02-04 06:57:25 -08:00
Martijn Otto fb742ba06d Keep a local copy of the string in the envelope, so that the data does not go out of scope 2014-01-28 15:06:20 +01:00
Emiel Bruijntjes 42f61a65bf Copy constructor added to Login class 2014-01-26 12:02:23 -08:00
Emiel Bruijntjes aba769f5cb monitor class moved from include directory to src 2014-01-06 13:34:54 -08:00
Emiel Bruijntjes a442a4773a use default compiler 2014-01-06 09:21:15 -08:00
Emiel Bruijntjes a9e6045414 Removed and implemented many @todo tags from the source code, and added extra safety checks if some ignorant user decides to destruct channels or objects while they are still in use, implemented correct closing handshake for both connections and channels 2014-01-06 08:15:21 -08:00
Emiel Bruijntjes d1ab8b179a implemented returned messages 2014-01-06 06:49:31 -08:00
Emiel Bruijntjes efc556ee0a added support for recovering 2014-01-06 05:38:48 -08:00
Emiel Bruijntjes 5a636f5b57 Implemented nack/reject 2014-01-06 05:28:58 -08:00
Emiel Bruijntjes d1ae133f42 implemented channel.ack() method 2014-01-05 12:21:09 -08:00
Emiel Bruijntjes cf1cbfa551 implemented consuming, refactored a lot of code from cpp files to header files 2014-01-05 09:50:41 -08:00
Emiel Bruijntjes 5269f51a92 Implemented setting the quality of service (and it turns out that the prefetch size is not implemented in rabbitMQ, nor is setting the qos for the entire connection, so we have only implemented it for a channel) 2014-01-05 05:19:35 -08:00
Emiel Bruijntjes 5e96e2d832 it now is possible to publish messages to an exchange with this library 2014-01-05 04:08:35 -08:00
Emiel Bruijntjes 9c1e44f512 First setup for implementing the publish method 2014-01-04 12:01:02 -08:00
Emiel Bruijntjes e5b705b742 Implemented buffering of outgoing messages before the connection is set up, so that it is possible to create channel objects and call AMQP methods even while the connection handshake is still in progress 2014-01-04 11:34:36 -08:00
Emiel Bruijntjes a6fc442bc5 updated docblocks and readme file 2014-01-04 09:20:45 -08:00
Emiel Bruijntjes 7a6527dddf updated Makefile, removed vhost from Login object, now also the commit of the README file and the header files 2014-01-04 05:11:06 -08:00
Emiel Bruijntjes ea4f82ac8f Initial commit with the implementation of all methods apart from the publish and consume methods 2014-01-04 03:45:04 -08:00