, 여러 버스 을 구성 할 수 없습니다 완전히을 XML 형식으로 처리하지만 동일한 프로세스 내에서 여러 버스 인스턴스를 시작할 수 없게합니다.
나는 종종 이렇게했습니다. 물리적으로 분리 된 배포 비용을 들이지 않고도 여러 논리적 끝점을 호스팅하려는 Azure 작업자 역할에서, 그리고 때로는 Topshelf에서 호스팅하는 Windows Services에서도 수행했습니다.
일반적으로, 내 app.config에 다음과 같은 XML과 끝 :
<rebus workers="1">
<add messages="SomeAssembly.Messages" endpoint="someEndpoint.input"/>
<add messages="AnotherAssembly.Messages" endpoint="anotherEndpoint.input"/>
</rebus>
이렇게 나를 한번에 버스 당 노동자와 엔드 포인트 매핑의 기본 개수를 구성 할 수 있습니다. 그런 다음 응용 프로그램이 시작되면 응용 프로그램 수명 기간 동안 버스 당 IoC 컨테이너가 유지됩니다. Windsor를 사용하면 대개 대기열 이름에 대한 매개 변수가있는 일반 버스 설치 프로그램으로 끝납니다. Windsor를 구성 할 수 있습니다 이와 같은 (A 윈저기구 임) RebusInstaller
가 근본적으로 단지 용기, 예를 들면 오른쪽으로 큐 이름 버스두고
var containers = new List<IWindsorContainer> {
new WindsorContainer()
// always handlers first
.Install(FromAssembly.Containing<SomeEndpoint.SomeHandler>())
// and then the bus, which gets started at this point
.Install(new RebusInstaller("someEndpoint.input", "error"))
// and then e.g. background timers and other "living things"
.Install(new PeriodicTimersInstannce()),
new WindsorContainer()
.Install(FromAssembly.Containing<AnotherEndpoint.AnotherHandler>())
.Install(new RebusInstaller("anotherEndpoint.input", "error"))
};
// and then remember to dispose each container when shutting down the process
이런 식으로 :
Configure.With(new WindsorContainerAdapter(container))
.Transport(t => t.UseMsmq(_inputQueueName, _errorQueueName))
.(...) etc
.CreateBus().Start();
저는 각 IoC 컨테이너 인스턴스가 논리적으로 독립적 인 응용 프로그램으로 작동한다는 생각을 좋아합니다. 이렇게하면 나중에 예를 들어 원하는 경우 시간을 따로 나누는 것이 쉬울 것입니다. 엔드 포인트를 독립적으로 배치 할 수 있어야합니다.
나는 이것이 당신에게 영감을 줄 수 있기를 바랍니다. 더 많은 포인터가 필요한지 물어보십시오.
흥미로운 답변을 주셔서 감사합니다. 나는 일반적으로 Ninject를 IoC로 사용한다. 각 작업자에게 전용 버스를 삽입하기 위해 문맥 바인딩이있는 단일 컨테이너를 사용하여 비슷한 접근법을 시도 할 것입니다. – Ganto