Browse Source

Make messages persistent by default. (#840)

pull/851/head
Adam 3 years ago committed by GitHub
parent
commit
05c0d1cc58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/EventSubscriber/StompHeaderEventSubscriber.php

14
src/EventSubscriber/StompHeaderEventSubscriber.php

@ -37,15 +37,16 @@ class StompHeaderEventSubscriber implements EventSubscriberInterface {
*/ */
public static function getSubscribedEvents() { public static function getSubscribedEvents() {
return [ return [
StompHeaderEventInterface::EVENT_NAME => ['baseAuth', -100], StompHeaderEventInterface::EVENT_NAME => ['baseHeaders', -100],
]; ];
} }
/** /**
* Event callback; generate and add base authorization header if none is set. * Event callback; generate and add base/default headers if not set.
*/ */
public function baseAuth(StompHeaderEventInterface $stomp_event) { public function baseHeaders(StompHeaderEventInterface $stomp_event) {
$headers = $stomp_event->getHeaders(); $headers = $stomp_event->getHeaders();
if (!$headers->has('Authorization')) { if (!$headers->has('Authorization')) {
$token = $this->auth->generateToken(); $token = $this->auth->generateToken();
if (empty($token)) { if (empty($token)) {
@ -58,6 +59,13 @@ class StompHeaderEventSubscriber implements EventSubscriberInterface {
} }
} }
// In ActiveMQ, STOMP messages are not persistent by default; however, we
// would like them to persist, by default... make it so, unless something
// else has already set the header.
if (!$headers->has('persistent')) {
$headers->set('persistent', 'true');
}
} }
} }

Loading…
Cancel
Save