You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Timothy A. Bish (Jira)" <ji...@apache.org> on 2023/04/06 19:00:00 UTC

[jira] [Commented] (ARTEMIS-4234) EmbeddedActiveMQResource is able to receive only first message

    [ https://issues.apache.org/jira/browse/ARTEMIS-4234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17709480#comment-17709480 ] 

Timothy A. Bish commented on ARTEMIS-4234:
------------------------------------------

I took a quite look at the code for the EmbeddedActiveMQResource receive methods and they are indeed a bit odd (and lacking docs to indicate what the expectations should be).  The receive method creates and internal receiver for getting this singular message and then never closes it or stores it for additional use so it would seem to be leaking receiver resources.  At the very least I'd have expected the code to close the receiver when done since the intent of the implementation sort of leans that way. 

> EmbeddedActiveMQResource is able to receive only first message
> --------------------------------------------------------------
>
>                 Key: ARTEMIS-4234
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4234
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 2.28.0
>            Reporter: Dominik Kawczyński
>            Priority: Major
>
> Hi,
> i have encountered a problem with embedded Artemis.
> Using *EmbeddedActiveMQResource* _receiveMessage_ method im able to receive only one message from queue.
> Please look at following code:
> {code:java}
> artemis.start()
> def firstMessage = 'test message 1'
> sendMessage(firstMessage, 'test_queue')
> def firstReceivedMessage = artemis.receiveMessage('test_queue', 1000)
> println('>>>>>>>> FIRST MESSAGE:')
> println('>>>>>>>>' + firstReceivedMessage.stringBody)
> /*
> will work if artemis is restarted during test
> artemis.stop()
> artemis.start()
> */
> def secondMessage = 'test message 2'
> sendMessage(secondMessage, 'test_queue')
> def secondReceivedMessage = artemis.receiveMessage('test_queue', 1000)
> println('>>>>>>>> SECOND MESSAGE:')
> println('>>>>>>>>' + secondReceivedMessage.stringBody)
> then:
> firstMessage == firstReceivedMessage.stringBody
> secondMessage == secondReceivedMessage.stringBody {code}
> I'm getting null as secondReceivedMessage, and NPE in effect later.
>  
> The reason is (i assume) that first invocation  is creating a consumer, that is getting second message, before i invoke receiveMessage method second time (i see in logs that second message was consumed)
>  
> Is this expected behavior?
> receiveMessage is returning only one message, so my assumption was, that i can invoke it several times to retrieve consequential messages, and i have not found any documentation explaining current behavior.
>  
> I have created repo with reproducible example:
> [https://github.com/dmkaw/embedded-artemis-issue]
>  
> Thanks in advance.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)