Monday, January 5, 2009

Link to Cloud Workflow Orchestration by NetEventRelayBinding


Cloud Workflow XAML:
Action -- http://www.jqd.com/cloud/IAlert/VIXAlert
[Namespace in WCF contract]/WCF Contract/MethodName
IMPORTANT --- MUST END W/O SLASH
Body --- <VIXAlert xmlns="http://www.jqd.com/cloud/"><msg>VIXUnder40</msg></VIXAlert>
<methodname xmlns="[Namespace]"><paramName>..
Url ---- sb://servicebus.windows.net/services/jqdsolution/anything/
Listener:

TransportClientEndpointBehavior cred =
new TransportClientEndpointBehavior();
cred.CredentialType = TransportClientCredentialType.UserNamePassword;
cred.Credentials.UserName.UserName = "jqdsolution";
cred.Credentials.UserName.Password = "xxxxxx";

NetEventRelayBinding nerb = new NetEventRelayBinding();

ServiceHost host = new ServiceHost(typeof(AlertListener),
new Uri("sb://servicebus.windows.net/services/jqdsolution/anything/")
);
host.AddServiceEndpoint("VIXAlertListener.IAlert", nerb, "sb://servicebus.windows.net/services/jqdsolution/anything/");

host.Description.Endpoints[0].Behaviors.Add(cred);
host.Open();
Console.WriteLine("VIX Listener Ready");
Console.ReadLine();
host.Close();
Handle firewall port blocking using HTTP mode:

ServiceBusEnvironment.OnewayConnectivity.Mode = ConnectivityMode.Http;
ServiceBusEnvironment.OnewayConnectivity.HttpModeRelayClientCredentials = cred;
ServiceBusEnvironment.OnewayConnectivity.HttpModeMessageBufferLocation = new Uri("http://servicebus.windows.net/services/jqdsolution/VIXAlertListener/" + Guid.NewGuid().ToString());
WCF Code:

[ServiceContract(Name = "IAlert", Namespace = "http://jqd.com/cloud/")]
public interface IAlert
{
[OperationContract(IsOneWay=true)]
void VIXAlert(string msg);
}

[ServiceBehavior(Name = "AlertListener", Namespace = "http://jqd.com/cloud/")]
public class AlertListener : IAlert
{

public void VIXAlert(string msg)
{
Console.WriteLine("Got Alert: " + msg);
}
}

Note that Namespace must match those in Cloud WF Action and NetEventRelayBinding
assume OneWay

No comments: