我有一个以recive Activity开头的工作流程。我主持这样的WF:
static void Main(string[] args)
{
string queueName = @ConfigurationManager.AppSettings["ServiceQueue"];
if (!MessageQueue.Exists(queueName))
{
MessageQueue.Create(queueName, true);
Console.WriteLine("Message Queue {0} created", queueName);
Console.WriteLine("Press <enter> to exit");
Console.ReadLine();
return;
}
WorkflowServiceHost host = PruebasAdslServiceHost.CreateWorkflowServiceHost();
host.Open();
Console.ReadLine();
host.Close();
}
打开主机没有问题,但是当我在队列中放入一条消息时,工作流程有一些错误进入故障状态。我认为在Recive Activity中有一些错误或类似的东西。我把de WF的代码放在这里:
public static class PruebasAdslServiceHost
{
public static WorkflowServiceHost CreateWorkflowServiceHost()
{
WorkflowService service = new WorkflowService()
{
Body = PruebasAdslSequences.CreateBody(),
Endpoints =
{
new System.ServiceModel.Endpoint
{
Binding = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(MsmqIntegrationSecurityMode.None),//("MsmqIntegrationBindingsTx"),
AddressUri = new Uri(ConfigurationManager.AppSettings["ServiceHostQueue"]),
ServiceContractName = XName.Get(PruebasAdslSequences.poContractDescription.Name)
}
}
};
WorkflowServiceHost workflowServiceHost = new WorkflowServiceHost(service);
// agregamos behaviors
/* IServiceBehavior idleBehavior = new WorkflowIdleBehavior { TimeToUnload = TimeSpan.Zero };
workflowServiceHost.Description.Behaviors.Add(idleBehavior);*/
IServiceBehavior workflowUnhandledExceptionBehavior = new WorkflowUnhandledExceptionBehavior()
{
Action = WorkflowUnhandledExceptionAction.AbandonAndSuspend // this is also the default
};
workflowServiceHost.Description.Behaviors.Add(workflowUnhandledExceptionBehavior);
// agregamos constr para el manejo de las instancias en base
SqlWorkflowInstanceStoreBehavior instanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior()
{
ConnectionString = ConfigurationManager.ConnectionStrings["ServiceProcessSampleStore"].ToString()
};
workflowServiceHost.Description.Behaviors.Add(instanceStoreBehavior);
//Agregamos que el wf se baje por el delay del proceso asi no queda en memoria esperando
WorkflowIdleBehavior workflowIdleBehavior = new WorkflowIdleBehavior()
{
TimeToUnload = TimeSpan.FromSeconds(0)
};
workflowServiceHost.Description.Behaviors.Add(workflowIdleBehavior);
// agregamos un endpoint mas por net pipe para tener un endpoind administrado
ServiceEndpoint workflowControlEndpoint = new WorkflowControlEndpoint()
{
Binding = new System.ServiceModel.NetNamedPipeBinding(System.ServiceModel.NetNamedPipeSecurityMode.None),
Address = new System.ServiceModel.EndpointAddress("net.pipe://workflowInstanceControl")
};
workflowServiceHost.AddServiceEndpoint(workflowControlEndpoint);
// agregamos el servicio de traking para ver los estados de las activiadades
workflowServiceHost.WorkflowExtensions.Add(new TrackingListenerConsole());
foreach (ServiceEndpoint ep in workflowServiceHost.Description.Endpoints)
{
Console.WriteLine(ep.Address);
}
return workflowServiceHost;
}
}
序列的身体在这里:
public class PruebasAdslSequences
{
public static ContractDescription poContractDescription = ContractDescription.GetContract(typeof(IPruebasAdsl));
public static Activity CreateBody()
{
Variable<PruebasAdslReq> pruebaAdsl = new Variable<PruebasAdslReq> { Name = "message" };
Variable<MsmqMessage<PruebasAdslReq>> pruebaAdslQueue = new Variable<MsmqMessage<PruebasAdslReq>> { Name = "queue" };
Sequence sequence = new Sequence
{
Variables =
{
pruebaAdsl,
pruebaAdslQueue
},
Activities =
{
new Receive
{
OperationName = "EjecutarPruebasADSL",
ServiceContractName = XName.Get(poContractDescription.Name),
CanCreateInstance = true,
Content = new ReceiveMessageContent
{
Message = new OutArgument<MsmqMessage<PruebasAdslReq>>(pruebaAdslQueue),
DeclaredMessageType = typeof(MsmqMessage<PruebasAdslReq>)
}
},
new PruebasAdslActivitys
{
RequestPruebas = new InArgument<PruebasAdslReq> (x=> pruebaAdslQueue.Get(x).Body)
},
}
};
return sequence;
}
}
对这个问题有任何想法吗?在此之前,我正在使用带有NetMsmqBinding的wf,它运行正常。
感谢