[ https://issues.apache.org/jira/browse/AMQNET-637?focusedWorklogId=743998&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-743998 ]
ASF GitHub Bot logged work on AMQNET-637: ----------------------------------------- Author: ASF GitHub Bot Created on: 18/Mar/22 14:56 Start Date: 18/Mar/22 14:56 Worklog Time Spent: 10m Work Description: Havret commented on a change in pull request #18: URL: https://github.com/apache/activemq-nms-openwire/pull/18#discussion_r829461300 ########## File path: src/Commands/ActiveMQMessage.cs ########## @@ -91,7 +92,13 @@ public void Acknowledge() Acknowledger(this); } - public virtual void ClearBody() + public Task AcknowledgeAsync() + { + Acknowledge(); Review comment: This is blocking. Shouldn't be as the internal implementation isn't. ########## File path: src/Util/Synchronization/NmsSynchronizationMonitor.cs ########## @@ -0,0 +1,314 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Apache.NMS.ActiveMQ.Util.Synchronization +{ + /// <summary> + /// Goal of this is to replace lock(syncRoot) for sync and async methods, and also have Wait and Pulse(All) capabilities + /// Relies on AsyncLocal construct, and should be valid along the flow of executioncontext + /// </summary> + public class NmsSynchronizationMonitor Review comment: I wonder why you didn't use sth like https://www.nuget.org/packages/Nito.AsyncEx/ and reimplemented this from scratch yourself. :thinking: ########## File path: src/IDispatcher.cs ########## @@ -25,6 +26,6 @@ namespace Apache.NMS.ActiveMQ /// </summary> public interface IDispatcher { - void Dispatch(MessageDispatch messageDispatch); + Task Dispatch_Async(MessageDispatch messageDispatch); Review comment: Why not `DispatchAsync`? ########## File path: src/ISynchronization.cs ########## @@ -15,24 +15,26 @@ * limitations under the License. */ +using System.Threading.Tasks; + namespace Apache.NMS.ActiveMQ { public interface ISynchronization { /// <summary> /// Called before a commit or rollback is applied. /// </summary> - void BeforeEnd(); + Task BeforeEndAsync(); Review comment: I hope nobody was using this public API. ########## File path: src/MessageConsumer.cs ########## @@ -667,7 +693,8 @@ public void DeliverAcks() this.executor = new ThreadPoolExecutor(); } - this.executor.QueueUserWorkItem(AsyncDeliverAck, ack); + // queue to sync pool so we have to make it sync method + this.executor.QueueUserWorkItem( (obj) => AsyncDeliverAckAsync(obj).GetAsyncResult(), ack); Review comment: That's pretty strange, but I guess it makes sense. ########## File path: src/Transport/FutureResponse.cs ########## @@ -15,77 +15,23 @@ * limitations under the License. */ -using System; -using System.Threading; +using System.Threading.Tasks; using Apache.NMS.ActiveMQ.Commands; -using Apache.NMS.Util; namespace Apache.NMS.ActiveMQ.Transport { /// <summary> /// Handles asynchronous responses /// </summary> - public class FutureResponse + public class FutureResponse : TaskCompletionSource<Response> { - private TimeSpan maxWait = TimeSpan.FromMilliseconds(Timeout.Infinite); - public TimeSpan ResponseTimeout + public FutureResponse(): base(TaskCreationOptions.RunContinuationsAsynchronously) { - get { return maxWait; } - set { maxWait = value; } } - - private readonly CountDownLatch latch = new CountDownLatch(1); - private Response response; - + public Response Response { - // Blocks the caller until a value has been set - get - { - lock(latch) - { - if(null != response) - { - return response; - } - } - - try - { - if(!latch.await(maxWait) && response == null) - { - throw new RequestTimedOutException(maxWait); - } - } - catch(RequestTimedOutException e) - { - Tracer.Error("Caught Timeout Exception while waiting on monitor: " + e); - throw; - } - catch(Exception e) - { - Tracer.Error("Caught Exception while waiting on monitor: " + e); - } - - if(response == null && maxWait.TotalMilliseconds > 0) - { - } - - lock(latch) - { - return response; - } - } - - set - { - lock(latch) - { - response = value; - } - - latch.countDown(); - } + set => SetResult(value); Review comment: This is not safe, it will throw an exception when you call `SetCanceled` or `SetException` first. I'd change it here and in other places to Try* equivalent. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 743998) Time Spent: 18.5h (was: 18h 20m) > NMS 2.0 > ------- > > Key: AMQNET-637 > URL: https://issues.apache.org/jira/browse/AMQNET-637 > Project: ActiveMQ .Net > Issue Type: Improvement > Components: NMS > Affects Versions: 1.8.0 > Reporter: Michael Andre Pearce > Priority: Major > Fix For: API-2.0.0 > > Time Spent: 18.5h > Remaining Estimate: 0h > > NMS API is still at JMS 1.1 api level, this is to update the NMS api to the > latest JMS 2.0 apiĀ -- This message was sent by Atlassian Jira (v8.20.1#820001)