Skip to content

Commit ca417ab

Browse files
committed
provide integer-equivalent expiration times to publish
1 parent dfb9a72 commit ca417ab

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

commands.lisp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ messages in between sending the cancel method and receiving the cancel-ok reply.
596596
(:method ((class amqp::channel) &key &allow-other-keys)
597597
class)))
598598

599+
(defparameter *publish-expiration* "100000"
600+
"Value in milliseconds. COuld also be a default value in the instance, but this is more direct,")
599601

600602
(def-amqp-command amqp:publish (class &key body exchange routing-key mandatory immediate
601603
content-type content-encoding headers delivery-mode
@@ -625,6 +627,7 @@ any, is committed.")
625627
(:method ((basic amqp:basic) &rest args &key (body nil body-s)
626628
(exchange nil e-s) (routing-key nil rk-s)
627629
(user-id (or (basic-user-id basic) ""))
630+
(expiration *publish-expiration*)
628631
&allow-other-keys)
629632
(when e-s
630633
(setf exchange (amqp:exchange-exchange exchange)) ; coerce to a string
@@ -636,7 +639,8 @@ any, is committed.")
636639
(remf args :body))
637640
(apply #'shared-initialize basic t args)
638641
(let ((channel (object-channel basic)))
639-
(apply #'device-write-content channel body :exchange exchange :user-id user-id args)))))
642+
(apply #'device-write-content channel body :exchange exchange :user-id user-id
643+
:expiration expiration args)))))
640644

641645

642646
(def-amqp-command amqp:purge (class &key queue no-wait)

readmes/example-streams.lisp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@
3434
(read-line input))
3535

3636

37+
;;; fails
38+
39+
DEVICE-READ: Required device state USE-CHANNEL.BODY.INPUT is not satisfied by #<USE-CHANNEL
40+
41+
{1001DFFF11}>.
42+
43+
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
44+
45+
restarts (invokable by number or by possibly-abbreviated name):
46+
0: [CONTINUE] Retry assertion.
47+
1: [ABORT ] Exit debugger, returning to top level.
48+
49+
(SB-KERNEL:ASSERT-ERROR
50+
(TYPEP #:G360 'AMQP.S:USE-CHANNEL.BODY.INPUT)
51+
NIL
52+
"~@[~a: ~]Required device state ~a is not satisfied by ~a."
53+
DEVICE-READ
54+
AMQP.S:USE-CHANNEL.BODY.INPUT
55+
#<AMQP.S:USE-CHANNEL {1001DFFF11}>)
56+
0]
57+
3758

3859
(amqp:with-open-channel (output *c* :exchange "ex" :type "direct" :queue "q1")
3960
(let ((message '("there" "comes" "a" "time" "when" "the" "mind" "takes" "a" "higher" "plane"
@@ -49,4 +70,6 @@
4970
(amqp:with-open-channel (input *c* :queue "q1")
5071
(loop
5172
(unless (print (read-line input nil nil))
52-
(return))))
73+
(return))))
74+
75+
(close *c* :abort t)

readmes/examples.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
(amqp:request-publish *ch1.basic* :exchange *ch1.ex*
5454
:body (format nil "a test message")
5555
:routing-key "foaf")
56+
;; should yield the message
5657
(amqp:request-get *ch2.basic* :queue *ch2.q*)
58+
;; should be empty
5759
(amqp:request-get *ch1.basic* :queue *ch1.q*))
5860

5961
#|

0 commit comments

Comments
 (0)