Skip to content

Commit 55c9df2

Browse files
committed
add inprocmessageconsumer interface
1 parent 7bfde50 commit 55c9df2

7 files changed

Lines changed: 147 additions & 133 deletions

File tree

Src/iFramework.Plugins/iFramework.MessageQueue.ZeroMQ/DistributableCommandBus.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ namespace IFramework.MessageQueue.ZeroMQ
1414
{
1515
public class DistributableCommandBus : CommandBus, ICommandBus
1616
{
17-
IMessageConsumer _CommandConsumer;
17+
IInProcMessageConsumer _CommandConsumer;
18+
IInProcMessageConsumer _CommandDistributor;
19+
1820
bool _IsDistributor;
19-
IMessageDistributor _CommandDistributor;
2021

2122
public DistributableCommandBus(ICommandHandlerProvider handlerProvider,
2223
ILinearCommandManager linearCommandManager,
2324
IMessageConsumer commandConsumer,
2425
string receiveEndPoint,
2526
bool inProc)
2627
: base(handlerProvider, linearCommandManager, receiveEndPoint, inProc)
27-
{
28-
_CommandConsumer = commandConsumer;
29-
_CommandDistributor = _CommandConsumer as IMessageDistributor;
30-
_IsDistributor = _CommandDistributor != null;
28+
{
29+
_CommandConsumer = commandConsumer as IInProcMessageConsumer;
30+
_CommandDistributor = _CommandConsumer as IInProcMessageConsumer;
31+
_IsDistributor = _CommandDistributor is IMessageDistributor;
3132
}
3233

3334

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{9636759C-63BC-470E-B95C-E120FBCB830B}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>IFramework.MessageQueue.ZeroMQ</RootNamespace>
11-
<AssemblyName>IFramework.MessageQueue.ZeroMQ</AssemblyName>
12-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
15-
<RestorePackages>true</RestorePackages>
16-
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18-
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<DebugType>pdbonly</DebugType>
28-
<Optimize>true</Optimize>
29-
<OutputPath>bin\Release\</OutputPath>
30-
<DefineConstants>TRACE</DefineConstants>
31-
<ErrorReport>prompt</ErrorReport>
32-
<WarningLevel>4</WarningLevel>
33-
</PropertyGroup>
34-
<ItemGroup>
35-
<Reference Include="clrzmq">
36-
<HintPath>..\..\..\packages\clrzmq.3.0.0-rc1\lib\net40\clrzmq.dll</HintPath>
37-
</Reference>
38-
<Reference Include="Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
39-
<SpecificVersion>False</SpecificVersion>
40-
<HintPath>..\..\..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
41-
</Reference>
42-
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
43-
<HintPath>..\..\..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
44-
</Reference>
45-
<Reference Include="System" />
46-
<Reference Include="System.Core" />
47-
<Reference Include="System.Xml.Linq" />
48-
<Reference Include="System.Data.DataSetExtensions" />
49-
<Reference Include="Microsoft.CSharp" />
50-
<Reference Include="System.Data" />
51-
<Reference Include="System.Xml" />
52-
</ItemGroup>
53-
<ItemGroup>
54-
<Compile Include="CommandBus.cs" />
55-
<Compile Include="CommandConsumer.cs" />
56-
<Compile Include="CommandDistributor.cs" />
57-
<Compile Include="DistributableCommandBus.cs" />
58-
<Compile Include="DomainEventBus.cs" />
59-
<Compile Include="EventPublisher.cs" />
60-
<Compile Include="MessageConsumer.cs" />
61-
<Compile Include="DomainEventSubscriber.cs" />
62-
<Compile Include="MessageFrame.cs" />
63-
<Compile Include="MessageQueueImpl.cs">
64-
<SubType>Code</SubType>
65-
</Compile>
66-
<Compile Include="MessageState.cs" />
67-
<Compile Include="Properties\AssemblyInfo.cs" />
68-
</ItemGroup>
69-
<ItemGroup>
70-
<ProjectReference Include="..\..\iFramework\IFramework.csproj">
71-
<Project>{f3932367-d3ea-4e8a-ab12-5fb785b93a39}</Project>
72-
<Name>IFramework</Name>
73-
</ProjectReference>
74-
<ProjectReference Include="..\IFramework.MessageQueue.MessageFormat\IFramework.MessageQueue.MessageFormat.csproj">
75-
<Project>{d33b2d5c-a9cd-43ed-bf45-a0e54fcc9789}</Project>
76-
<Name>IFramework.MessageQueue.MessageFormat</Name>
77-
</ProjectReference>
78-
</ItemGroup>
79-
<ItemGroup>
80-
<None Include="libzmq.dll">
81-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82-
</None>
83-
<None Include="packages.config" />
84-
</ItemGroup>
85-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9636759C-63BC-470E-B95C-E120FBCB830B}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>IFramework.MessageQueue.ZeroMQ</RootNamespace>
11+
<AssemblyName>IFramework.MessageQueue.ZeroMQ</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
15+
<RestorePackages>true</RestorePackages>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="clrzmq">
36+
<HintPath>..\..\..\packages\clrzmq.3.0.0-rc1\lib\net40\clrzmq.dll</HintPath>
37+
</Reference>
38+
<Reference Include="Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
39+
<SpecificVersion>False</SpecificVersion>
40+
<HintPath>..\..\..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
43+
<HintPath>..\..\..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
44+
</Reference>
45+
<Reference Include="System" />
46+
<Reference Include="System.Core" />
47+
<Reference Include="System.Xml.Linq" />
48+
<Reference Include="System.Data.DataSetExtensions" />
49+
<Reference Include="Microsoft.CSharp" />
50+
<Reference Include="System.Data" />
51+
<Reference Include="System.Xml" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Compile Include="CommandBus.cs" />
55+
<Compile Include="CommandConsumer.cs" />
56+
<Compile Include="CommandDistributor.cs" />
57+
<Compile Include="DistributableCommandBus.cs" />
58+
<Compile Include="DomainEventBus.cs" />
59+
<Compile Include="EventPublisher.cs" />
60+
<Compile Include="IInProcMessageConsumer.cs" />
61+
<Compile Include="MessageConsumer.cs" />
62+
<Compile Include="DomainEventSubscriber.cs" />
63+
<Compile Include="MessageFrame.cs" />
64+
<Compile Include="MessageQueueImpl.cs">
65+
<SubType>Code</SubType>
66+
</Compile>
67+
<Compile Include="Properties\AssemblyInfo.cs" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<ProjectReference Include="..\..\iFramework\IFramework.csproj">
71+
<Project>{f3932367-d3ea-4e8a-ab12-5fb785b93a39}</Project>
72+
<Name>IFramework</Name>
73+
</ProjectReference>
74+
<ProjectReference Include="..\IFramework.MessageQueue.MessageFormat\IFramework.MessageQueue.MessageFormat.csproj">
75+
<Project>{d33b2d5c-a9cd-43ed-bf45-a0e54fcc9789}</Project>
76+
<Name>IFramework.MessageQueue.MessageFormat</Name>
77+
</ProjectReference>
78+
</ItemGroup>
79+
<ItemGroup>
80+
<None Include="libzmq.dll">
81+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82+
</None>
83+
<None Include="packages.config" />
84+
</ItemGroup>
85+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8686
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
8787
Other similar extension points exist, see Microsoft.Common.targets.
8888
<Target Name="BeforeBuild">
8989
</Target>
9090
<Target Name="AfterBuild">
9191
</Target>
92-
-->
92+
-->
9393
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using IFramework.Message;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace IFramework.MessageQueue.ZeroMQ
8+
{
9+
public interface IInProcMessageConsumer : IMessageConsumer
10+
{
11+
void EnqueueMessage(object message);
12+
}
13+
}

Src/iFramework.Plugins/iFramework.MessageQueue.ZeroMQ/MessageConsumer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace IFramework.MessageQueue.ZeroMQ
1414
{
15-
public abstract class MessageConsumer<TMessage> : IMessageConsumer
15+
public abstract class MessageConsumer<TMessage> : IInProcMessageConsumer
1616
where TMessage : class
1717
{
1818
protected BlockingCollection<TMessage> MessageQueue { get; set; }

Src/iFramework/IFramework.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<Compile Include="Event\IEventSubscriber.cs" />
108108
<Compile Include="Event\IEventSubscriberProvider.cs" />
109109
<Compile Include="Event\Impl\EventSubscriberProvider.cs" />
110+
<Compile Include="Message\MessageState.cs" />
110111
<Compile Include="SysException\NoCommandHandlerExists.cs" />
111112
<Compile Include="Infrastructure\CookieHelper.cs" />
112113
<Compile Include="Infrastructure\DisposeObjectHttpModule.cs" />
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
namespace IFramework.Message
7-
{
8-
public interface IMessageConsumer
9-
{
10-
void Start();
11-
string GetStatus();
12-
void EnqueueMessage(object message);
13-
decimal MessageCount { get; }
14-
}
15-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace IFramework.Message
7+
{
8+
public interface IMessageConsumer
9+
{
10+
void Start();
11+
string GetStatus();
12+
decimal MessageCount { get; }
13+
}
14+
}

Src/iFramework.Plugins/iFramework.MessageQueue.ZeroMQ/MessageState.cs renamed to Src/iFramework/Message/MessageState.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using IFramework.Message;
2-
using IFramework.Message.Impl;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Security.Principal;
7-
using System.Text;
8-
using System.Threading;
9-
using System.Threading.Tasks;
10-
11-
namespace IFramework.MessageQueue.ZeroMQ
12-
{
13-
public class MessageState
14-
{
15-
public MessageState() { }
16-
public MessageState(IMessageContext messageContext)
17-
{
18-
MessageContext = messageContext;
19-
}
20-
internal string MessageID { get; set; }
21-
internal CancellationToken CancellationToken { get; set; }
22-
internal IMessageContext MessageContext { get; set; }
23-
internal TaskCompletionSource<object> TaskCompletionSource { get; set; }
24-
}
25-
}
1+
using IFramework.Message;
2+
using IFramework.Message.Impl;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Security.Principal;
7+
using System.Text;
8+
using System.Threading;
9+
using System.Threading.Tasks;
10+
11+
namespace IFramework.Message
12+
{
13+
public class MessageState
14+
{
15+
public MessageState() { }
16+
public MessageState(IMessageContext messageContext)
17+
{
18+
MessageContext = messageContext;
19+
}
20+
public string MessageID { get; set; }
21+
public CancellationToken CancellationToken { get; set; }
22+
public IMessageContext MessageContext { get; set; }
23+
public TaskCompletionSource<object> TaskCompletionSource { get; set; }
24+
}
25+
}

0 commit comments

Comments
 (0)