Commit Graph

189 Commits

Author SHA1 Message Date
Karl Nilsson 802688a8ab
AMQP 1.0: Support the modified outcome
Some client libraries (QPid) will automatically send a disposition
with the 'modified' outcome in response to a client local message TTL
expiry.

To support this case and others we treat 'modified' the same as
'accepted' and simply ack the message back to the queue.

This change also contains some API extensions to the amqp10_client
to better support sending the various delivery states (outcomes).
2022-10-24 10:22:07 -07:00
Luke Bakken 7fe159edef
Yolo-replace format strings
Replaces `~s` and `~p` with their unicode-friendly counterparts.

```
git ls-files *.erl | xargs sed -i.ORIG -e s/~s>/~ts/g -e s/~p>/~tp/g
```
2022-10-10 10:32:03 +04:00
Steve Hall f7b3e63ee0
he ssl:ssl_option() type was renamed to ssl:tls_option() in this commit: e042afe547 which was merged in OTP 21.3
This change prevents dialyzer warning:
```
:0:unknown_type
Unknown type: :ssl.ssl_option/0.
```
2022-09-17 11:54:44 +01:00
Chunyi Lyu c8ee8f45e6 Connect ssl:connect in amqp10_client with hostname
- instead of tcp socket
2022-08-16 12:47:32 +01:00
Michael Klishin c38a3d697d
Bump (c) year 2022-03-21 01:21:56 +04:00
Philip Kuryloski 226e00fcd2 Tighten up dialyzer usage
now that rules_erlang no longer cascades up dialyzer warnings from deps
2022-02-24 11:18:41 +01:00
Karl Nilsson 3f667a3cb8 amqp10_client: make shutdown scenarios a bit less noisy
by handling specific EXIT and DOWN messages that may occur during
certain connection closure cases.
2021-10-13 14:30:46 +01:00
Philip Kuryloski 3715616afb Replace deprecated function calls in amqp10_client
http_uri:decode/1 -> uri_string:percent_decode/1
2021-05-20 16:52:55 +02:00
Michael Klishin 97ff62d3b2
Drop trailing newlines from logged messages where possible
Lager strips trailing newline characters but OTP logger with the default
formatter adds a newline at the end. To avoid unintentional multi-line log
messages we have to revisit most messages logged.

Some log entries are intentionally multiline, others
are printed to stdout directly: newlines are required there
for sensible formatting.
2021-03-11 15:17:37 +01:00
Michael Klishin b11a79cccf
Bump (c) year in header files 2021-02-04 07:04:58 +03:00
Michael Klishin 52479099ec
Bump (c) year 2021-01-22 09:00:14 +03:00
Michael Klishin 3713ccfa2b Squash a compiler warning introduced in #56 2020-08-14 17:53:59 +03:00
Tom Storck c866d080cf Handle detach frame when closed set to false 2020-08-14 08:34:20 +02:00
sircinek b5bdfb6574 Update amqp10_client_session.erl
Remove `ct:pal/2` calls from production code (these prints to stdout).
2020-08-04 22:16:21 +02:00
kjnilsson 4284f205bd Switch remaining processes to gen_statem 2020-07-24 15:38:50 +01:00
Antoine Gagné 37f6a35dde Convert frame reader to `gen_statem` 2020-07-23 15:04:46 +01:00
Antoine Gagné 3ac16fbe91 Add type specification 2020-07-23 15:02:46 +01:00
kjnilsson cc501f987d Use ssl:sslsocket instead of ssl:socket
This allows dialyzer to pass without dialyzer directives.
2020-07-23 13:08:03 +01:00
Philip Kuryloski f46bac3d8b Corrections for various dialyzer warnings 2020-07-23 13:08:03 +01:00
dcorbacho 42fbdeb19f Remove unused file 2020-07-14 22:03:35 +01:00
dcorbacho 177c269fc7 Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-10 14:39:32 +01:00
Michael Klishin 4b883566b9 Revert "Merge pull request #49 from AntoineGagne/feature/migrate-to-gen-statem-frame-reader"
This reverts commit 5291bdc1e5, reversing
changes made to 53c3db7f07.

We cannot migrate just frame reader; client connection and other
processes need to be migrated as well. As things stand right now,
the client does not compile from scratch.
2020-05-13 00:43:36 +03:00
Antoine Gagné c3adec4e67 Convert frame reader to `gen_statem` 2020-05-09 19:00:04 -04:00
Antoine Gagné 1e8af97f53 Add type specification 2020-05-09 18:44:32 -04:00
k fe018ac513 sasl supports more errors 2020-05-08 10:26:04 +02:00
Luke Bakken e139665736 Encode boolean values specifically
Follow-up to #45
2020-04-30 20:01:55 +00:00
Luke Bakken 3dba14bed8 Take atoms into account
Fixes #45
2020-04-30 18:44:18 +00:00
Jean-Sébastien Pédron b2b4887534 Update copyright (year 2020) 2020-03-10 17:04:51 +01:00
Michael Klishin 29785ce008 Support lists of endpoints
that are tried in sequence until one of them succeeds.

Per discussion with @kjnilsson.
2020-02-21 17:48:46 +03:00
Michael Klishin ddcb9191a6 Make it possible for connection starter to opt out of failure notifications
and prefer monitoring the pid instead. This is convenient when
the owner tries to connect to N endpoints and some of them fail,
sending a notification for each connection attempt instead of just
the successful one.
2020-02-20 17:05:02 +03:00
Jean-Sébastien Pédron 0508240ec7 amqp10_client_connection: Handle heartbeat in close_sent/2
This message, sent by the timer module, may happen in the `close_sent`
state. We can ignore it but we still need to handle it.

I saw this case happen in CI:

*** System report during system_SUITE:init_per_group/2 for activemq 2020-02-12 06:06:06.473 ***
=WARNING REPORT==== 12-Feb-2020::06:06:06.473178 ===
terminating connection with reason '{function_clause,
                                     [{amqp10_client_connection,close_sent,
                                       [heartbeat,
                                        {state,2,<0.455.0>,
(...)
2020-02-12 15:39:31 +01:00
Michael Klishin cb15a20636 Log less on abrupt socket closure 2020-02-12 03:58:41 +03:00
Michael Klishin 46bbafe66a This test breaks on OTP 21's uri_string 2019-12-29 20:18:08 +03:00
Michael Klishin 6367904515 Reduce dependency on http_uri for warning-free OTP 23 compatibility
Note that http_uri:decode/1 doesn't have a counterpart in uri_string
so an exception feels appropriate.
2019-12-29 19:40:37 +03:00
Michael Klishin 913d2bfe0b (c) bump 2019-12-29 05:50:22 +03:00
Diana Corbacho 38e6cd4ea6 Replace timer:send_after/3 by erlang:send_after/3
[#167926549]
2019-08-17 20:45:56 +01:00
Antoine Gagné 0d2b94a048 Fix type specification 2019-08-08 16:10:40 -04:00
Antoine Gagné 65fac9578a Add working properties 2019-08-08 16:07:50 -04:00
Antoine Gagné 3c0c50b762 WIP: Add sketchy properties 2019-08-08 15:02:41 -04:00
Antoine Gagné 9deede03e4 WIP: Add attach properties 2019-08-08 13:55:38 -04:00
kjnilsson 5ba7597300 URI parser: allow the container_id to be set 2019-05-08 10:50:05 +01:00
kjnilsson 5ed06bbb68 Uri parser: return error when path segments are used 2019-05-08 09:48:40 +01:00
Michael Klishin ed054e2e2f Merge pull request #25 from rabbitmq/echo-flow-state
Add function to request flow state from sender
2019-05-07 19:41:36 +03:00
Jean Bouchard 2003561b02 update all the filters 2019-03-20 11:06:45 -04:00
Jean Bouchard bc1eb6193e update 2019-03-20 08:42:15 -04:00
Jean Bouchard 28c0b7e1b4 dirty hack the filter 2019-03-20 08:38:57 -04:00
kjnilsson bd38baa3be Add function to request flow state from sender
It is part of the spec although RabbitMQ doesn't implement it.
2019-03-06 13:47:30 +00:00
kjnilsson 7bda227517 Provide scheme defualts when parsing URIs
Else uri parsing will fail when explicit ports aren't provided.
2019-02-20 10:31:06 +00:00
kjnilsson c7a4333e9e Remove commented out code
[#161256187]
2018-10-26 09:36:57 +01:00
kjnilsson 2c98f67aa0 Add API for client to pass the drain flag
[#161256187]
2018-10-24 17:55:14 +01:00
kjnilsson 5138be18e6 Add amqp10_msg:body_bin/1 function
To allow users to get a binary representation of the body (which may be
amqp 1.0 encoded). Currently it re-encodes the decoded value, in the
future we can optimise this by delaying the actual body decoding until
it is needed. (if it ever is).

[#159434026]
2018-08-13 15:23:40 +01:00
Michael Klishin d416fe145d OTP 19.3 compatibility 2018-08-13 00:13:37 +03:00
kjnilsson 3afc76630a URI decode user and password when parsing
Usernames and passwords in the amqp URI may be URI encoded. Ensure we
decode them during URI parse.

[#159650732]
2018-08-10 11:22:48 +01:00
kjnilsson d44ac69679 improve URI support
This change includes three improvements:

1. Support configuring tls versions through the uri. Previusly this
could only be done in code or by configururing the application
environment.
2. Default the hostname connection property to the URI host if no
hostname query parameter was found.
3. Make sasl=plain implicit if the URI contains a username and password.

[#159650732]
2018-08-09 10:50:54 +01:00
kjnilsson 9a3c409e71 Make compatible with amqp10_common changes
The array representation was changed and needed updating.

[#156613309]
2018-04-23 12:13:34 +01:00
Patrick Detlefsen b8e5b4e0a0 translate_filters tests 2018-04-07 18:24:24 +02:00
Patrick Detlefsen 55860b5e5e export attach_receiver_link/6 2018-04-07 15:29:39 +02:00
Patrick Detlefsen e8e599380c export filter type and add comment 2018-03-24 15:40:16 +01:00
Patrick Detlefsen 982c78e89c more readable formatting 2018-03-23 13:50:10 +01:00
Patrick Detlefsen 20c8ea6c93 Allow passing of filters in attach receiver 2018-03-23 13:38:40 +01:00
kjnilsson c66617343b Add test for large message sizes.
Set a more sensible default for max_frame_size that works better with
large messages.

Clean up partial transfers on completion.
2017-12-21 16:21:22 +00:00
kjnilsson c68aa1a202 Handle transfer frames without deliver_id
Fixes bug where continuation frames without a delivery_id were not
handled.

Also re-enables tests using the mock server.

[#153702031]
2017-12-19 15:51:26 +00:00
kjnilsson fdc0719c7c typespec fixes 2017-12-12 15:32:39 +00:00
Luke Bakken 37a971637d Ensure user and pass are binaries 2017-12-11 17:41:05 -08:00
Luke Bakken a809b14f36 Add support for server_name_indication in AMQP URI
See PT story [153560059]

See rabbitmq/rabbitmq-erlang-client#95
2017-12-11 11:37:38 -08:00
Jean-Sébastien Pédron 0b665d6244 With Erlang 20, turn off warning about deprecated gen_fsm
Specifying '+{nowarn_deprecated_functions, [...]}' on the command line
didn't appear to work, so I put those directives in source files and
used a define to enable it.
2017-10-16 17:40:57 +02:00
kjnilsson 42ec995f69 Refine and comment connection config 2017-06-07 17:10:12 +01:00
kjnilsson 3b5ce0b96c Only auto flow based on settled transfers.
Previously we'd auto flow more credit to sender after a certain number
of received transfer whether they have been settled or not. This changes
the approach to keep a separate counter of transfers that have been
settled and only grant more credit once this falls below the requested
limit. It isn't a perfect approach but it is much better than what was
there before which would effectively have the effect of providing no
flow control.
2017-06-07 16:46:15 +01:00
kjnilsson 3e2ff91c96 Disable debug logging 2017-05-26 16:51:04 +01:00
kjnilsson 1edeb64ce7 add attach_sender_link_sync/5 2017-05-09 11:37:40 +01:00
kjnilsson 4304640f38 Add api overload to configure durability during attach
It is a fairly commonly used configuration option.
2017-05-08 13:25:31 +01:00
kjnilsson 45fb64fda7 dialyzer fixes 2017-05-08 11:29:01 +01:00
kjnilsson 631d094ba5 Monitor reader in case socket is closed
The connection process won't know if the socket is closed
as it is the reader that owns the socket. By monitoring the
reader the connection can at least close and notify closure.
2017-05-08 11:16:57 +01:00
kjnilsson 7c237ae0e4 merge 2017-05-04 17:54:12 +01:00
kjnilsson 095897e04f Treat unexpected socket closures as errors.
AMQP 1.0 requires connection closure to follow protocol.
Hence we treat unexpected socket closures as errors and
avoid trying to terminate the supervisor as this can
cause a race condition when the connection tries to do
the same.
2017-05-02 12:05:13 +01:00
kjnilsson a86a249844 Terminius durabuility
Expose attach_link/2 that takes and AttachArgs map so that we can
specify the terminus durability during attach.
2017-05-02 12:02:22 +01:00
kjnilsson 967511c5c4 Handle undefined delivery state.
IBM MQ returns an undefined delivery state when the link is detached
before the disposition is sent.
2017-05-02 12:00:32 +01:00
kjnilsson f4addfc122 correctly tag timestamps 2017-04-18 13:06:54 +01:00
kjnilsson 588709aa55 message and delivery annotation setters 2017-04-18 12:10:32 +01:00
kjnilsson 2b40d727eb fix issues encoding/decoding application_properties 2017-04-13 17:05:30 +01:00
kjnilsson 4b5c31b36a Turn certain debug messages into full error logs 2017-04-13 10:58:01 +01:00
kjnilsson c53a5098bd Add application_properties 2017-04-13 10:51:27 +01:00
kjnilsson ad195319d2 disable debug logging 2017-04-12 10:59:58 +01:00
kjnilsson e5eb41aabd Add license headers 2017-04-12 10:53:27 +01:00
kjnilsson 121b31473a add tls options to uri parser 2017-04-06 12:03:05 +01:00
kjnilsson 21d8a885ac fix type spec 2017-04-05 19:36:39 +01:00
kjnilsson 874b2023a0 basic amqp uri parser 2017-04-05 17:37:34 +01:00
kjnilsson 090f4a064f Docs and refactor to use link_refs in amqp10_link events 2017-04-04 17:07:14 +01:00
kjnilsson 9e01f3f8e5 move hrl file as not meant to be shared 2017-04-03 15:46:53 +01:00
kjnilsson 7790bc14fd README updates 2017-04-03 15:46:06 +01:00
kjnilsson 45276a5a0a Add README.md 2017-04-03 15:25:02 +01:00
kjnilsson ae79d197b3 document api modules 2017-04-03 13:10:45 +01:00
kjnilsson 2e4e39215b handle tcp errors 2017-04-03 11:58:06 +01:00
kjnilsson 4bf5effbfd implement flow auto-renewal 2017-04-03 11:44:40 +01:00
kjnilsson 22e48d0d0b report reason in detached event 2017-04-03 09:28:57 +01:00
kjnilsson 1419d83b6c set default message_format
Azure ServiceBus goes really weird without it.
2017-03-31 14:15:12 +01:00
kjnilsson 65064d8ea1 Tweaks for Servicebus 2017-03-31 12:20:21 +01:00
kjnilsson 245427cc96 Add basic ssl/tcl support 2017-03-30 10:48:15 +01:00
kjnilsson e702bc08b3 Implement PLAIN SASL auth 2017-03-29 16:57:59 +01:00
kjnilsson 204c0b8b90 make link attach/detach async 2017-03-28 11:21:03 +01:00