ZF-7948: Zend_Queue_Adapter_Activemq should not subscribe to messages receiving each time receive() method is called

Description

Zend_Queue_Adapter_Activemq should subscribe to messages only once for a given queue. This bug produces a new subscriber in Apache ActiveMQ broker each time receive() is called.

Method should send subscription frame only first time it is called.

Comments

This is affecting all current versions.

This is still a current bug i may look into this to find out if there is a simple fix.

Anton, Please, feel free to do so!

Torio,

From what i see there is a new function needed for the Zend_Queue_Adapter_Activemq component.

In the example:

I would suggest migrating the subscribe function out to it's own function as this is really the only fix i see that works cleanest.

see my attached patch

Or making a driver option subscribe = true/false so you can set it in the options to subscribe or not and have it subscribed on init.

This is the patch for Zend_Queue_Adapter_Activemq

Test case for this patch.

Works with patch fails without. Provided by mjh_ca

Attaching revised patch with clean-ups. Waiting for Anton to run the online activemq tests against an activemq server to confirm that everything passes with the changes.

Anton-Swartzs-MacBook-Pro:~ necrogami$ cd ZF Anton-Swartzs-MacBook-Pro:ZF necrogami$ patch -p0 < ./ZF-7948.patch patching file tests/Zend/Queue/Adapter/ActivemqOfflineTest.php patching file tests/Zend/Queue/AllTests.php patching file library/Zend/Queue/Adapter/Activemq.php Anton-Swartzs-MacBook-Pro:ZF necrogami$ cd tests Anton-Swartzs-MacBook-Pro:tests necrogami$ zf .svn/ AllTests.php TestConfiguration.php TestHelper.php Zend/ resources/ runtests.sh
Anton-Swartzs-MacBook-Pro:tests necrogami$ ./runtests.sh Zend_Queue ++ phpunit --verbose --group Zend_Queue AllTests PHPUnit 3.4.9 by Sebastian Bergmann.

Zend Framework Zend Framework - Zend Zend Framework - Zend_Queue Zend_Queue_FactoryTest SS..

Zend_Queue_Queue1Test .............

Zend_Queue_Queue2Test .........S...

Zend_Queue_MessageTest .....

Zend_Queue_Message_IteratorTest ........

Zend_Queue_Adapter_ArrayTest S....................

Zend_Queue_Adapter_MemcacheqTest .SSSSSSSSSSSSSSSSSS

Zend_Queue_Adapter_DbTest S.SSSSSSSSSSSSSSSSSS

Zend_Queue_Adapter_NullTest ...S.SSSSSSSS....S.

Zend_Queue_Adapter_PlatformJobQueueTest SSSSSSSSSSSSSSSSSSSS

Zend_Queue_Stomp_FrameTest ....

Zend_Queue_Stomp_ClientTest ....

Zend_Queue_Adapter_ActivemqTest .SSSSSSSSSSSSSSSSSS

Zend_Queue_Adapter_ActivemqOfflineTest .

Time: 19 seconds, Memory: 388.50Mb

There were 89 skipped tests:

1) Zend_Queue_FactoryTest::testDb Db setup required

/Users/necrogami/ZF/tests/Zend/Queue/FactoryTest.php:58

2) Zend_Queue_FactoryTest::testMemcacheq MemcacheQ setup required

/Users/necrogami/ZF/tests/Zend/Queue/FactoryTest.php:80

3) Zend_Queue_Queue2Test::testSendAndCountAndReceiveAndDeleteMessage send/count/receive are not supported

/Users/necrogami/ZF/tests/Zend/Queue/QueueBaseTest.php:183

4) Zend_Queue_Adapter_ArrayTest::testConst no constants to test

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/ArrayTest.php:94

5) Zend_Queue_Adapter_MemcacheqTest::testGetOptions

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:176

6) Zend_Queue_Adapter_MemcacheqTest::testZendQueueAdapterConstructor

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:244

7) Zend_Queue_Adapter_MemcacheqTest::testZendQueueMessageTest

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:257

8) Zend_Queue_Adapter_MemcacheqTest::testFactory

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:290

9) Zend_Queue_Adapter_MemcacheqTest::testCreate

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:298

10) Zend_Queue_Adapter_MemcacheqTest::testDelete

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:323

11) Zend_Queue_Adapter_MemcacheqTest::testIsExists

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:351

12) Zend_Queue_Adapter_MemcacheqTest::testSend

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:382

13) Zend_Queue_Adapter_MemcacheqTest::testReceive

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:413

14) Zend_Queue_Adapter_MemcacheqTest::testDeleteMessage

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:450

15) Zend_Queue_Adapter_MemcacheqTest::testGetQueues

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:494

16) Zend_Queue_Adapter_MemcacheqTest::testCount

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:521

17) Zend_Queue_Adapter_MemcacheqTest::testCapabilities

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:571

18) Zend_Queue_Adapter_MemcacheqTest::testIsSupported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:597

19) Zend_Queue_Adapter_MemcacheqTest::testGetQueue

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:618

20) Zend_Queue_Adapter_MemcacheqTest::testSampleBehavior

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:635

21) Zend_Queue_Adapter_MemcacheqTest::testVisibility

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:695

22) Zend_Queue_Adapter_MemcacheqTest::testIsSupportException

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:792

23) Zend_Queue_Adapter_DbTest::testConst no constants to test

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/DbTest.php:110

24) Zend_Queue_Adapter_DbTest::testGetOptions

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:176

25) Zend_Queue_Adapter_DbTest::testZendQueueAdapterConstructor

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:244

26) Zend_Queue_Adapter_DbTest::testZendQueueMessageTest

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:257

27) Zend_Queue_Adapter_DbTest::testFactory

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:290

28) Zend_Queue_Adapter_DbTest::testCreate

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:298

29) Zend_Queue_Adapter_DbTest::testDelete

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:323

30) Zend_Queue_Adapter_DbTest::testIsExists

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:351

31) Zend_Queue_Adapter_DbTest::testSend

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:382

32) Zend_Queue_Adapter_DbTest::testReceive

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:413

33) Zend_Queue_Adapter_DbTest::testDeleteMessage

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:450

34) Zend_Queue_Adapter_DbTest::testGetQueues

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:494

35) Zend_Queue_Adapter_DbTest::testCount

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:521

36) Zend_Queue_Adapter_DbTest::testCapabilities

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:571

37) Zend_Queue_Adapter_DbTest::testIsSupported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:597

38) Zend_Queue_Adapter_DbTest::testGetQueue

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:618

39) Zend_Queue_Adapter_DbTest::testSampleBehavior

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:635

40) Zend_Queue_Adapter_DbTest::testVisibility

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:695

41) Zend_Queue_Adapter_DbTest::testIsSupportException

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:792

42) Zend_Queue_Adapter_NullTest::testZendQueueMessageTest send() receive() are not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:269

43) Zend_Queue_Adapter_NullTest::testCreate create() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:306

44) Zend_Queue_Adapter_NullTest::testDelete delete() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:331

45) Zend_Queue_Adapter_NullTest::testIsExists isExists() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:359

46) Zend_Queue_Adapter_NullTest::testSend send() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:390

47) Zend_Queue_Adapter_NullTest::testReceive receive() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:421

48) Zend_Queue_Adapter_NullTest::testDeleteMessage deleteMessage() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:458

49) Zend_Queue_Adapter_NullTest::testGetQueues getQueues() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:502

50) Zend_Queue_Adapter_NullTest::testCount count() is not supported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:529

51) Zend_Queue_Adapter_NullTest::testVisibility Null does not support visibility of messages

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:703

52) Zend_Queue_Adapter_PlatformJobQueueTest::testFailedConstructor

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

53) Zend_Queue_Adapter_PlatformJobQueueTest::testZendQueueMessageTest

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

54) Zend_Queue_Adapter_PlatformJobQueueTest::testSend

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

55) Zend_Queue_Adapter_PlatformJobQueueTest::testReceive

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

56) Zend_Queue_Adapter_PlatformJobQueueTest::testDeleteMessage

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

57) Zend_Queue_Adapter_PlatformJobQueueTest::testCount

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

58) Zend_Queue_Adapter_PlatformJobQueueTest::testSampleBehavior

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

59) Zend_Queue_Adapter_PlatformJobQueueTest::testVisibility

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

60) Zend_Queue_Adapter_PlatformJobQueueTest::testConst

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

61) Zend_Queue_Adapter_PlatformJobQueueTest::testGetOptions

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

62) Zend_Queue_Adapter_PlatformJobQueueTest::testZendQueueAdapterConstructor

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

63) Zend_Queue_Adapter_PlatformJobQueueTest::testFactory

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

64) Zend_Queue_Adapter_PlatformJobQueueTest::testCreate

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

65) Zend_Queue_Adapter_PlatformJobQueueTest::testDelete

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

66) Zend_Queue_Adapter_PlatformJobQueueTest::testIsExists

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

67) Zend_Queue_Adapter_PlatformJobQueueTest::testGetQueues

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

68) Zend_Queue_Adapter_PlatformJobQueueTest::testCapabilities

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

69) Zend_Queue_Adapter_PlatformJobQueueTest::testIsSupported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

70) Zend_Queue_Adapter_PlatformJobQueueTest::testGetQueue

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

71) Zend_Queue_Adapter_PlatformJobQueueTest::testIsSupportException

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/PlatformJobQueueTest.php:57

72) Zend_Queue_Adapter_ActivemqTest::testGetOptions

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:176

73) Zend_Queue_Adapter_ActivemqTest::testZendQueueAdapterConstructor

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:244

74) Zend_Queue_Adapter_ActivemqTest::testZendQueueMessageTest

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:257

75) Zend_Queue_Adapter_ActivemqTest::testFactory

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:290

76) Zend_Queue_Adapter_ActivemqTest::testCreate

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:298

77) Zend_Queue_Adapter_ActivemqTest::testDelete

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:323

78) Zend_Queue_Adapter_ActivemqTest::testIsExists

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:351

79) Zend_Queue_Adapter_ActivemqTest::testSend

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:382

80) Zend_Queue_Adapter_ActivemqTest::testReceive

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:413

81) Zend_Queue_Adapter_ActivemqTest::testDeleteMessage

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:450

82) Zend_Queue_Adapter_ActivemqTest::testGetQueues

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:494

83) Zend_Queue_Adapter_ActivemqTest::testCount

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:521

84) Zend_Queue_Adapter_ActivemqTest::testCapabilities

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:571

85) Zend_Queue_Adapter_ActivemqTest::testIsSupported

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:597

86) Zend_Queue_Adapter_ActivemqTest::testGetQueue

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:618

87) Zend_Queue_Adapter_ActivemqTest::testSampleBehavior

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:635

88) Zend_Queue_Adapter_ActivemqTest::testVisibility

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:695

89) Zend_Queue_Adapter_ActivemqTest::testIsSupportException

/Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:151 /Users/necrogami/ZF/tests/Zend/Queue/Adapter/AdapterTest.php:792 OK, but incomplete or skipped tests! Tests: 170, Assertions: 370, Skipped: 89.

Anton, the Activemq test was skipped:

Zend_Queue_Adapter_ActivemqTest
.SSSSSSSSSSSSSSSSSS

You need to re-run and ensure that TestConfiguration.php.dist is copied to TestConfiguration.php and configured to test against your local activemq.

Check the source again. They will ALWAYS be skipped because Zend_Queue_Adapter_Activemq does NOT support creating a queue which is the first call on every test. which causes them to be skipped.

Updated patch. Found & corrected problem in ActivemqTest which was using wrong constant name. Online ActiveMQ tests now run as expected.

Installed Activemq locally to test. Tests in the latest patch run clean including the Activemq tests which are no longer skipped if configured in TestConfiguration.php.

Marking as resolved. Applied to trunk in r23498, merged to release branch 1.11 in r23499.