File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
src/Savorboard.CAP.InMemoryMessageQueue Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public void Subscribe(IEnumerable<string> topics)
3737 {
3838 _queue . Subscribe ( _groupId , OnConsumerReceived , topic ) ;
3939
40- _logger . LogInformation ( $ "InMemory message queue initialize the topic: { topic } ") ;
40+ _logger . LogInformation ( $ "InMemory message queue initialize the topic: { _groupId } { topic } ") ;
4141 }
4242 }
4343
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
34using DotNetCore . CAP . Messages ;
45using Microsoft . Extensions . Logging ;
56
@@ -44,19 +45,18 @@ public void ClearSubscriber()
4445
4546 public void Send ( TransportMessage message )
4647 {
47- foreach ( var groupTopic in _groupTopics )
48+ var name = message . GetName ( ) ;
49+ foreach ( var groupTopic in _groupTopics . Where ( o => o . Value . Item2 . Contains ( name ) ) )
4850 {
49- if ( groupTopic . Value . Item2 . Contains ( message . GetName ( ) ) )
51+ try
5052 {
51- try
52- {
53- message . Headers [ Headers . Group ] = groupTopic . Key ;
54- groupTopic . Value . Item1 ? . Invoke ( message ) ;
55- }
56- catch ( Exception e )
57- {
58- _logger . LogError ( e , $ "Consumption message raises an exception. Group-->{ groupTopic . Key } Name-->{ message . GetName ( ) } ") ;
59- }
53+ var message_copy = new TransportMessage ( message . Headers . ToDictionary ( o => o . Key , o => o . Value ) , message . Body ) ;
54+ message_copy . Headers [ Headers . Group ] = groupTopic . Key ;
55+ groupTopic . Value . Item1 ? . Invoke ( message_copy ) ;
56+ }
57+ catch ( Exception e )
58+ {
59+ _logger . LogError ( e , $ "Consumption message raises an exception. Group-->{ groupTopic . Key } Name-->{ name } ") ;
6060 }
6161 }
6262 }
You can’t perform that action at this time.
0 commit comments