You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2019/09/08 22:52:00 UTC

[jira] [Work logged] (AMQNET-610) Race condition during consumer creation

     [ https://issues.apache.org/jira/browse/AMQNET-610?focusedWorklogId=308564&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-308564 ]

ASF GitHub Bot logged work on AMQNET-610:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Sep/19 22:51
            Start Date: 08/Sep/19 22:51
    Worklog Time Spent: 10m 
      Work Description: Havret commented on pull request #29: AMQNET-610: Race conditions during consumer creation
URL: https://github.com/apache/activemq-nms-amqp/pull/29
 
 
   It closes https://issues.apache.org/jira/projects/AMQNET/issues/AMQNET-610
   
   @michaelandrepearce @cjwmorgan-sol Could you please take a look? 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 308564)
    Remaining Estimate: 0h
            Time Spent: 10m

> Race condition during consumer creation
> ---------------------------------------
>
>                 Key: AMQNET-610
>                 URL: https://issues.apache.org/jira/browse/AMQNET-610
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: AMQP, NMS
>            Reporter: Krzysztof Porebski
>            Priority: Critical
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Working on CI I found a race condition that reveals itself on slower machines and may result in losing messages by consumers. 
> The race condition is a result of treating the creation of consumer resources and starting them as an atomic operation:
> {code:java}
> public async Task Init()
> {
>     await Session.Connection.CreateResource(Info);
>     await Session.Connection.StartResource(Info);
> }
> {code}
> On slower boxes pending message may be delivered to the provider before above code returns:
> {code:java}
> public IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal)
> {
>     CheckClosed();    NmsMessageConsumer messageConsumer = new NmsMessageConsumer(consumerIdGenerator.GenerateId(), this, destination, selector, noLocal);
>     messageConsumer.Init().ConfigureAwait(false).GetAwaiter().GetResult();
> // here may be a race condition    
> consumers.TryAdd(messageConsumer.Info.Id, messageConsumer);
>     
>     return messageConsumer;
> }
> {code}
> If message arrives before `Init` returns (which means before newly created consumer is added to the list of available consumers), the message will be ignored. 
> {code:java}
> public void OnInboundMessage(InboundMessageDispatch envelope)
> {
>     if (consumers.TryGetValue(envelope.ConsumerInfo.Id, out NmsMessageConsumer messageConsumer))
>     {
>         messageConsumer.OnInboundMessage(envelope);
>     }
> }
> {code}
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)