|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* AppserverIo\Messaging\AbstractMessageListener |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/appserver-io/messaging |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\Messaging; |
|
22
|
|
|
|
|
23
|
|
|
use AppserverIo\Psr\Pms\MessageInterface; |
|
24
|
|
|
use AppserverIo\Psr\Pms\MessageListenerInterface; |
|
25
|
|
|
use AppserverIo\Psr\Pms\MessageQueueException; |
|
26
|
|
|
use AppserverIo\Psr\Pms\QueueContextInterface; |
|
27
|
|
|
use AppserverIo\Psr\EnterpriseBeans\Annotations as EPB; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* An abstract implementation for a message listener. |
|
31
|
|
|
* |
|
32
|
|
|
* @author Tim Wagner <[email protected]> |
|
33
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
|
34
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
35
|
|
|
* @link https://github.com/appserver-io/messaging |
|
36
|
|
|
* @link http://www.appserver.io |
|
37
|
|
|
*/ |
|
38
|
|
|
abstract class AbstractMessageListener implements MessageListenerInterface |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* The application instance that provides the entity manager. |
|
43
|
|
|
* |
|
44
|
|
|
* @var \AppserverIo\Psr\Application\ApplicationInterface |
|
45
|
|
|
* @EPB\Resource(name="ApplicationInterface") |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $application; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Returns the application instance. |
|
51
|
|
|
* |
|
52
|
|
|
* @return \AppserverIo\Psr\Application\ApplicationInterface The application instance |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getApplication() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->application; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Updates the message monitor over the applications queue manager method. |
|
61
|
|
|
* |
|
62
|
|
|
* @param \AppserverIo\Psr\Pms\MessageInterface $message The message to update the monitor for |
|
63
|
|
|
* |
|
64
|
|
|
* @return void |
|
65
|
|
|
* @throws \AppserverIo\Psr\Pms\MessageQueueException Is thrown if no queue manager is registered in the application |
|
66
|
|
|
*/ |
|
67
|
|
|
protected function updateMonitor(MessageInterface $message) |
|
68
|
|
|
{ |
|
69
|
|
|
|
|
70
|
|
|
// check if a application instance is available |
|
71
|
|
|
$queueManager = $this->getApplication()->search(QueueContextInterface::IDENTIFIER); |
|
|
|
|
|
|
72
|
|
|
if ($queueManager == null) { |
|
73
|
|
|
throw new MessageQueueException( |
|
74
|
|
|
sprintf('Can\'t find queue manager instance in application %s', $this->getApplication()->getName()) |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
// update the monitor |
|
79
|
|
|
$queueManager->updateMonitor($message); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.