File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed
Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 5050 // The message will be re-delivered after the specified time
5151 // $consumer->nack($message);
5252
53- } catch (MessageNotFound $ e ) {
54- echo "Message Not Found \n" ;
55- continue ;
53+ } catch (MessageNotFound $ e ) {
54+ // enum code see Exception/MessageNotFound.php
55+ $ code = $ e ->getCode ();
56+ if ($ code == MessageNotFound::Ignore) {
57+ continue ;
58+ }
59+
60+ throw $ e ;
5661 } catch (Throwable $ e ) {
5762 echo $ e ->getMessage ();
5863 throw $ e ;
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ public function receive(bool $loop = true): Message
204204 // It may appear that the current message is not CommandMessage
205205 if (!( $ commandMessage instanceof CommandMessage )) {
206206 if (!$ loop ) {
207- throw new MessageNotFound ();
207+ throw new MessageNotFound (' command parse fail ' , MessageNotFound::CommandParseFail );
208208 }
209209 return $ this ->receive ($ loop );
210210 }
Original file line number Diff line number Diff line change 1818class MessageNotFound extends Exception
1919{
2020
21+ /**
22+ * Can be ignored, not a err
23+ */
24+ const Ignore = 0 ;
25+
26+ /**
27+ * Command parsing failed
28+ */
29+ const CommandParseFail = 1 ;
30+
31+
2132 /**
2233 * @param string $message
34+ * @param int $code
2335 */
24- public function __construct (string $ message = 'Message Not Found ' )
36+ public function __construct (string $ message = 'Message Not Found ' , int $ code = MessageNotFound::Ignore )
2537 {
26- parent ::__construct ($ message );
38+ parent ::__construct ($ message, $ code );
2739 }
2840}
You can’t perform that action at this time.
0 commit comments