메시지를 큐 (MSMQ)에 쓰는 레거시 클라이언트가 있습니다. WCF 서비스를 사용하여 대기열 밖으로 XML 메시지를 가져 오려고했습니다. 나는 몇몇 MSFT 문서를 읽고 다른 예제를 훑어 보았지만 작동시키지 못했습니다. 서비스 호스트가 시작되고 있지만 프로세스를 시작하지 않고 대기열에서 메시지를 가져 오지 않습니다. 대부분의 사용자 오류, 확실하지 않은 무엇.WCF MsmqIntegrationBinding - 큐에서 메시지를 선택하지 않음
대기열에 메시지가 표시 될 수 있습니까?
코드 예 :
[ServiceContract]
[ServiceKnownType(typeof(XElement))]
public interface IMessageProcessor
{
[OperationContract(IsOneWay = true, Action = "*")]
void ProcessMessage(MsmqMessage<XElement> msg);
}
class MessageServiceClient : IMessageProcessor
{
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void ProcessMessage(MsmqMessage<XElement> msg)
{
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
Console.WriteLine("Processing {0} ", msg.ToString());
scope.Complete();
}
}
static void Main(string[] args)
{
Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]);
// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(MessageServiceClient), baseAddress))
{
// Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("The service is running in the following account: {0}");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
serviceHost.Close();
}
}
}
응용 프로그램 구성 :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- use appSetting to configure MSMQ queue name -->
<add key="QueueName" value=".\private$\MyMessageQueue" />
<add key="baseAddress" value="http://localhost:8000/test/message" />
</appSettings>
<system.serviceModel>
<services>
<service name="MessageServiceClient">
<!-- .Net endpoint-->
<endpoint address="msmq.formatname:DIRECT=OS:.\private$\MyMessageQueue"
binding="msmqIntegrationBinding"
bindingConfiguration="DotNetBinding"
contract="WcfServiceClient.IMessageProcessor" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MessageServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata />
<!--<serviceThrottling maxConcurrentCalls="20" maxConcurrentSessions="20" />-->
<serviceTimeouts />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<msmqIntegrationBinding>
<binding serializationFormat="ActiveX" name="ActiveXBinding" durable="false" exactlyOnce="false">
<security mode="None" />
</binding>
<binding serializationFormat="Xml" name="DotNetBinding" durable="false" exactlyOnce="false">
<security mode="None" />
</binding>
</msmqIntegrationBinding>
</bindings>
</system.serviceModel>
</configuration>
아니 내가 잘못하고있는 중이 야 무엇인지? 아래와 같은 설정에서
--S
귀하의 서비스 이름이 완전한 이름을 나타내지 않습니다. – Rajesh